2012-04-18 19 views
3

jCropに基づいてextednedプラグインを作成し、複数の画像を次々と切り抜くことができました。jCrop APIはnullまたはIEのオブジェクトではありませんが、FF、Chromeなどで動作します

Chromeを使用して開発してデバッグしましたが、JavaScriptの問題がなくてもすべて正常に動作しました。私はエクスプローラでテストするために来たとき、それは倒れたので、私のjavascriptのは、すべてのChromeの仕事と私ができることを単に...

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

ある

jcrop api is null or not an object

を書いたスクリプトエラーを投げましたグローバルトリガーを使用して画像を変更します。なぜ私はそれがIEで動作しないのか分かりません?

答えて

8

確かにjCropは、使用する正確な行をドキュメントに示しています。しかし、IEのJavaScriptエンジンは許しがたいです。あなたがする必要がどのような

var jcrop_api; 

$(document).ready(function() { 

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

が続いて残りを行い、VARにAPIを割り当てるには、このラインを使用しています。何らかの理由で、IEのthisが、jCropのコールバック関数の代わりにDOM全体に戻り、割り当てに失敗し、API変数は何も残されません。

この変更はChrome、FFなどには影響しません。また、どのようになってもさらに明確になります。

+1

+1あなたが私の週末を保存したため:)(私の頭から1つの問題を意味します) – Marecky

関連する問題