views:

18

answers:

2

Hi, 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

A: 

If you're using $.Jcrop() directly, it's expecting a jquery object or an element.

A usage example would look like this:

$.Jcrop($('#cropbox_full'),options);
Nick Craver
Seems to be a bug with chrome, according to the documentatio you could do: $.Jcrop('#cropbox_full',options); and if I remember correctly it does work with firefox.
Macario
A: 

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);
Macario