Cannot get access to the Jquery JCrop api
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
});
精彩评论