jquery - Img src changes but not the actual image -


i'm changing image clicking on button. can see in src code image changed, actual image isn't changing in browser. how come, , how solve it?

// avatargenerator.eyes = 1;  moverightbtn.on('click', function(){     var newimage = 'eyes' + (avatargenerator.eyes + 1) + '.png';      $('#eyesimg').attr('src','img/' + newimage); }); 

edit: created jsfiddle works, thing i'm using fabric.js (a canvas framework), may reason it's not working thought can't understand why. :(

your fabric.js code:

var canvas = new fabric.canvas('canvas');  var imginstance = new fabric.image(imgelement, {     left: 100,     top: 100,     angle: 30,     opacity: 0.85 });  canvas.add(imginstance); 

"stamps" visual copy of image onto canvas. canvas doesn't hold kind of reference of original image element, because canvas dumb grid of pixels. canvases don't know about represent, hold pixel data.

thus, when original image element used "stamp" changes, there's no reason "imprint" pixels on canvas change. instead, need re-run fabric.js code stamp new pixels onto canvas.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -