Trying to use Jcrop api

I use Jcrop, and I don’t want to dynamically change the aspect ratio for the selection based on user input, so I assume that the way to use is to use the Jcrop api.

The thing is, if I use it as a jquery function, it works fine:

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

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

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

Is this a Jcrop bug?

BTW I use chrome and jquery 1.4.2

+3
source share
4 answers

There seems to be some error when using chrome, because in firefox this works:

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

, jCrop , , , , chrome:

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

​​JCrop, , Google Chrome, FF, IE Safari. :

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

- :

        $(document).ready(function () {
            $('#cropbox_full').Jcrop({
                onSelect: storeCoords,
                setSelect: [0, 0, 114, 137],
                aspectRatio: 114 / 137,
                minSize: [114, 137]
            });
        });
+2

If you use $.Jcrop()directly, it expects a jquery object or element.

An example of use would look like this:

$.Jcrop($('#cropbox_full'),options);
+1
source

I had a similar problem today. I solved this by initializing Jcrop api in

$(window).load(function() { ... });

instead

$(document).ready(function() { ... });

which is common practice in jQuery.

+1
source

Source: https://habr.com/ru/post/1769464/


All Articles