Im using JQuery Context Menu plugin.
When the document is ready, I have contextMenu for img elements
$(document).ready(function(){
$('img').contextMenu({
menu: 'photoMenu'
},function(action, el, pos) {
//some function
});
});
I am going to add dynamically img element:
$img = $('<img />');
How to bind contextMenu for the newly created img element. It should be the same with the above? Should I create a function call it? Or there are other easy way for this?
Thanks.
Currently you are attaching your
contextMenuin your document ready function. You should create thecontextMenuafter the image is created.So just update your code to
Note: You have to make sure that you are creating the
contextMenuafter creating the image object.