How do I remove jcrop?

随声附和 提交于 2019-11-30 03:17:34

Edit: Looks like you need to maintain a reference to the api when you add jcrop to an image.

// assign jcrop to jcrop_api
var jcrop_api = $.Jcrop('#imgThumbnailer', {
    onChange: statusCrop,
    onSelect: statusCrop,
    bgColor: 'black',
    bgOpacity: .3
});


// when you want to remove it
jcrop_api.destroy();

I was wondering the same thing and after reading the source have found a simple solution that works in v0.9.8 (the other posted answers only work with the dev version currently). If you initiate Jcrop like this:

$('#imgThumbnailer').Jcrop({
    onChange: statusCrop,
    onSelect: statusCrop,
    bgColor: 'black',
    bgOpacity: .3
});

then you can get access to the api and destroy Jcrop via:

JcropAPI = $('#imgThumbnailer').data('Jcrop');
JcropAPI.destroy();

It's probably too late for the asker but hopefully this is helpful to someone who stumbles upon this page from google!

As of version v0.9.9 of Jcrop, you need to do it the following way:

var jcrop_api;
$('#target').Jcrop(options,function(){
    jcrop_api = this;
});

Courtesy of the creator: http://deepliquid.com/content/Jcrop_API.html

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!