Cropper: how to re-initialize cropper?

Created on 17 Jun 2016  路  9Comments  路  Source: fengyuanchen/cropper

How can I re-initialize cropper if I dynamically include path to cropper.js with

All 9 comments

Destroy it first, and then initialize again.

After the script reference is loaded into I'm trying to initialize it, but I get this error that copper is not a function, so there is nothing to destroy and $('#image').cropper returns the error

I guess you loaded a wrong script. Which one you are using?

I was using jquery based cropper and everything was working fine when the link was present in html.
Than new requirement came to load script on button click and it stopped working.
Now I tried JS based cropperjs and was able to use it, just have to re-write some old jquery code now, so I was thinking if it was possible to initialize jquery cropper.

There is no proper example for destroying the cropper session using jquery. In documentation it is written

`destroy()

Destroy the cropper and remove the instance from the image.`

But i don't understand where to write this code

@milpas999 $('img').cropper('destroy')

Hi...
And how destroy cropper using pure javascript?

If you have:

var cropper = new Cropper(image, {...});

Then you can destroy it by writing:

cropper.destroy();

But how to reinit after the destroy?
It is removing the element from the DOM.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hpolonkoev picture hpolonkoev  路  5Comments

WillJW picture WillJW  路  3Comments

rajjanorkar picture rajjanorkar  路  4Comments

SimonBriche picture SimonBriche  路  7Comments

jzahka picture jzahka  路  4Comments