单击按钮时删除/禁用jquery插件

时间:2015-11-18 13:26:16

标签: javascript jquery html

我正在使用jQuery ImageAreaSelect进行图像区域选择,如下所示:

 $('#image').imgAreaSelect({}); //#image is a img id

在此图片下方,我有一堆图片缩略图,点击该缩略图会将该图片填充为#image。这样,用户可以加载每个图像,然后选择其区域。

我的问题是,当加载新图像时,指示为先前图像选择的区域的虚线仍然保留并显示在新加载的图像上。我不想要这个,并希望每次加载新图像时它都会消失。

我阅读并尝试this answerthis answer,但他们不适合我...... 我目前的(非工作)代码是:

$('#load').click(function() {
    $('#image').imgAreaSelect({hide:true,remove:true}); //try to remove old instance
    $('#image').imgAreaSelect({}); //create new instance...
});

感谢任何帮助。

2 个答案:

答案 0 :(得分:0)

我从未使用过这样的插件,但文档解释了how to disable/re-enable it.

初始化插件时保存变量

var ias = $('#image').imgAreaSelect( // your original initalization

然后在文档中声明禁用它:

ias.setOptions({hide:true,remove:true})

答案 1 :(得分:0)

试试这种方式

$('#load').click(function() {
    $('#image').cancelSelection();
});
相关问题