fengyuanchen / cropper

⚠️ [Deprecated] No longer maintained, please use https://github.com/fengyuanchen/jquery-cropper
MIT License
7.75k stars 1.74k forks source link

It does not destroy after previous destroy #1050

Closed Tigrov closed 5 years ago

Tigrov commented 5 years ago

To Reproduce

  1. Create cropper var cropper = $('#img').cropper(options).data('cropper');
  2. Then destroy it cropper.destroy();
  3. Again create cropper = $('#img').cropper(options).data('cropper');
  4. And try to destroy cropper.destroy(); but it does not work.

Desktop:

Reason I suppose the reason is in the follow code if (!element[NAMESPACE]) { return this; } https://github.com/fengyuanchen/cropperjs/blob/master/dist/cropper.js#L2506

Because it sets to undefined after first destroy(), element[NAMESPACE] = undefined;

If I use cropper.uncreate(); it works fine.

fengyuanchen commented 5 years ago

You SHOULD destroy the cropper with $('#img').cropper('destroy') if you are using the jQuery version!