fengyuanchen / cropper

⚠️ [Deprecated] No longer maintained, please use https://github.com/fengyuanchen/jquery-cropper

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

It does not destroy after previous destroy

Tigrov opened this issue · comments

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:

  • OS: Windows 10,
  • Browser Chrome
  • Version 4.0.0

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.

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