It does not destroy after previous destroy
Tigrov opened this issue · comments
To Reproduce
- Create cropper
var cropper = $('#img').cropper(options).data('cropper');
- Then destroy it
cropper.destroy();
- Again create
cropper = $('#img').cropper(options).data('cropper');
- 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!