How do I remove jcrop?

后端 未结 3 747
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-28 18:04

how do i un-jcrop an image?

I\'m adding jcrop with a;

$(\'#imgThumbnailer\').Jcrop({
    onChange: statusCrop,
    onSelect: statusCrop,
    bgColor:         


        
相关标签:
3条回答
  • 2020-12-28 18:36

    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!

    0 讨论(0)
  • 2020-12-28 18:52

    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

    0 讨论(0)
  • 2020-12-28 18:53

    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();
    
    0 讨论(0)
提交回复
热议问题