jquery rotate plugin throwing uncaught exception

1

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(){
                //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 })
jquery
jquery-plugins
rotation
image-manipulation
asked on Stack Overflow Jun 6, 2011 by sadmicrowave

1 Answer

1

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.

answered on Stack Overflow Jun 6, 2011 by Pointy • edited Jun 6, 2011 by Pointy

User contributions licensed under CC BY-SA 3.0