开发者

Cannot get access to the Jquery JCrop api

开发者 https://www.devze.com 2023-04-13 05:31 出处:网络
I am trying to access to the jCrop api ( http://deepliquid.com ). Here is my code snippet : // The selected image has been loaded

I am trying to access to the jCrop api ( http://deepliquid.com ).

Here is my code snippet :

// The selected image has been loaded
$('#selectedImage').load(function() {
   var jcrop_开发者_高级运维api = $('#selectedImage').Jcrop({
                touchSupport:     true,
                onSelect: cropSelected
    });
    jcrop_api.setSelect([ 100,100,200,200 ]);
});

I get in the console : TypeError: Result of expression 'jcrop_api.setSelect' [undefined] is not a function.

I am aware that I can pass some parameters as options, but I would like to use the api to perform some other stuff (setImage, etc.)

Any ideas ? Thanks a lot !


You are calling the api in the wrong way...

change this:

   var jcrop_api = $('#selectedImage').Jcrop({
                touchSupport:     true,
                onSelect: cropSelected
    });

to this:

   var jcrop_api = $.Jcrop('#selectedImage',{
                touchSupport:     true,
                onSelect: cropSelected
    });
0

精彩评论

暂无评论...
验证码 换一张
取 消