I use croppie for editing pictures before uploading. The task is to destroy and init again this plugin without reloading the page.
So what I've already had:
$('#someID').croppie({
viewport: {
width: 128,
height: 128
}
});
$('#someID').croppie('bind', {
url: 'some base64 encoded image'
});
After some operations - I hide the plugin:
$('#someID').toggle();
$('#someID').croppie('bind');
After all there are cases when I need croppie again and first part of js code works again, so I have in console:
croppie.min.js:1 Uncaught Error: Croppie: Can't initialize croppie more than once
And obviously I just hafta check initialized plugin for current element now or not. What I found:
// it supposed to be the answer, however it doesn't work correctly for me.
if (!jQuery().fn.croppie) {
$('#someID').croppie({
viewport: {
width: 128,
height: 128
}
});
}
this answer - and it always true ('cause of it's included library and it returns function) and I can't check this way;
this one the same issue.
So, how to make sure that plugin initialized now or not?
P.S. It could be croppie or any other plugin. Thank you!