Closed ajitdas123 closed 6 years ago
Be sure the Cropper instance is ready and still there when you call it later.
@fengyuanchen , yes cropper is getting initialized before clicking on save.
If I place the save function inside crop like the code below it works.
result = $croppedImage.cropper({
ready: function() {
console.log('Cropper initialized');
},
aspectRatio: 1 / 1,
crop: function(e) {
$('#save').click(function(action) {
domElement.find('img').attr('src', $croppedImage.cropper('getCroppedCanvas').toDataURL());
domElement.removeClass('isSelected');
result.cropper('destroy');
})
}
})
However, after doing it with two, three images it crashes the webpage. :/ Can u please look into this. Thank you
The crop
option is an event shortcut which will be execute many many times, you must use $().once
method to bind event handler within it!
The
crop
option is an event shortcut which will be execute many many times, you must use$().once
method to bind event handler within it!
how?
I am using jquery cropper to achieve something like this below. Whenever the user clicks on an input that image will be sent to cropper canvas. And once the user saves the cropped image it will be loaded into the preview box and clear the cropper canvas.
This is what I am trying to achieve
But the problem with this is, this works great for the first input file. But when I try to do the same with next input it through
I could not figure out why this is happening when it works great for the first time.
My code is here below.
I added code to the jsFiddle here
Can anyone please tell me where I m doing wrong. Thanks