开发者

jquery rotate plugin throwing uncaught exception

开发者 https://www.devze.com 2023-03-10 13:39 出处:网络
I\'ve got a problem when implementing the jquery rotate plugin.I implement it like this: var iDirection = 90;

I've got a problem when implementing the jquery rotate plugin. I implement it like this:

var iDirection = 90;
var dImg = $("<img/>")
     .addClass('defect-image')
     .attr({src: $(this).attr('IMAGE_PATH')})
     .load(function(开发者_如何学Python){
                //do stuff if img loads without errors
             })
             .error(function(){
                $(this).attr({src: 'img/missing.jpg' });
             })
             .rotate( iDirection )
             .appendTo( '.image-container' );

The error I'm getting is this:

 Error: uncaught exception: 
 [Exception... "Component returned failure code: 
 0x80040111 (NS_ERROR_NOT_AVAILABLE) 
 [nsIDOMCanvasRenderingContext2D.drawImage]"  nsresult: "0x80040111
 (NS_ERROR_NOT_AVAILABLE)"  
 location: "JS frame :: http://my.domain.com/js/jquery.rotate.js :: anonymous :: line 51"  data: no]

I need help deciphering this error. I can't figure out what I'm doing wrong with this implementation. I've also tried (with no luck):

.rotate({angle: iDirection })


If I were you, I'd put the call to ".rotate()" inside the "load" handler, or in a "success" handler:

var dImg = $("<img/>")
 .addClass('defect-image')
 .attr({src: $(this).attr('IMAGE_PATH')})
 .load(function(){
            //do stuff if img loads without errors
         })
 .success(function() { dImg.rotate(iDirection); })

edit — this seems to be a case of a buggy jQuery plugin (this one). You might want to dig through the "Issues" list for that project and see if one of the patched versions helps, or you could pick a different plugin.

0

精彩评论

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