Search code examples
jqueryjquery-pluginsjcrop

Trying to use Jcrop api


I am using Jcrop and I wan't to dynamically change the aspect ratio for the selection based on user input, so I guess the way to go is to use Jcrop api.

Thing is that if I use it as a jquery function it works ok:

$('#cropbox_full').Jcrop({
  onChange: update_full_dimensions,
  onSelect: update_full_dimensions
});

But if I use it calling Jcrop function my image is no longer displayed:

var api = $.Jcrop('#cropbox_full', options);

Is it a Jcrop bug?

BTW I am using chrome and jquery 1.4.2


Solution

  • There seems to be some bug while using chrome because in firefox this works:

    $.Jcrop($('#cropbox_full'),options);
    

    After jCrop has been setted it can be accessed like this and options can be resetted, this worked with chrome:

    $('#cropbox_full').Jcrop(options);
    var jcrop = $('#cropbox_full').data('Jcrop');
    jcrop.setOptions(newOptions);