The JCrop API is null or not an object in IE, but works in FF, Chrome, etc.

I wrote an extedned plugin based on jCrop to crop mulitple images one by one.

I developed and debugged using Chrome, and everything worked perfectly without any JavaScript issues. When I came for a test in Explorer, it crashed and threw a script error that wrote out

jcrop api is null or not an object

So my javascript is just ...

var jcrop_api; //Global var to be used thorugh out the client

//some code here

//jCrop documention tells us to use this to assign itself to an object.
//I look for both because i use .net masterpages and sometimes not.

$('#SourceImage, #body_SourceImage').Jcrop({},function () { jcrop_api = this; });


//some more code but not far down the line i need to set jCrop options using API

jcrop_api.setOptions({
           boxWidth: bw,
           onSelect: updateCoords,
           minSize: [thisImage.Min.Width, thisImage.Min.Height],
           aspectRatio: thisImage.AspectRatio
       });
 jcrop_api.setImage('../cache/uploads/' + fileName);

That everything works in Chrome, and I can change images using a global trigger. I have no idea why this is not working in IE?

+3
source share
1 answer

Indeed, jCrop shows in the documentation the exact string you are using. But IE JavaScript engine is inexorable.

, , api var

var jcrop_api;

$(document).ready(function () {

jcrop_api = $.Jcrop($('#SourceImage, #body_SourceImage'), {});

. - this IE DOM jCrop , API .

Chrome, FF - .. .

+8

All Articles