odyniec / imgareaselect

ImgAreaSelect is a jQuery plugin for selecting a rectangular area of an image. It allows web developers to easily implement image cropping functionality, as well as other user interface features, such as photo notes (like those on Flickr).
http://odyniec.net/projects/imgareaselect/
686 stars 197 forks source link

Help needed about remove and cancelSelection #80

Open petrospap opened 9 years ago

petrospap commented 9 years ago

Hello First of all thanks for this very useful script. I need a help from you guys, my knowledge is not very good when it comes to javascript/jquery I have a page where I load an external file with $ajax, in this file I load another file where I call lot of images with imgAreaSelect i.e

$('#thump1').imgAreaSelect({ aspectRatio: '4:3',  onSelectChange: myfunction });
$('#thump2').imgAreaSelect({ aspectRatio: '4:3',  onSelectChange: myfunction });

is working as expected, but I have problem to remove imgAreaSelect with a click a button from the FIRST PAGE what is works (but I got problems also) is something like this

$(document).on('click', '.button', function(){
var ias = $('#thumb1').imgAreaSelect({instance:true});
    if (ias){
       ias.cancelSelection();
       ias.remove();
    };
});

cancelSelection works, remove is NOT working so if call cancelSelection in 2-3 images I got lot of hidden imgareaselect-outer divs I use jquery.imgareaselect.dev.js Can you please help me out here?