I am using a plugin called jQuery contextMenu but am having trouble making it work w开发者_如何转开发ith elements that are loaded via ajax after the DOM has already loaded. does anyone know how i can get this working with .live?
I've made a modification of the original jquery.contextMenu.js script. I've replaced .each()
with .live("mousedown", ...)
and deleted appropriate mousedown binding (you can also make a diff of my code and the original to get the changes).
You can get the code from http://pastebin.com/jBcAR6g1
Works for me.
2018 update without plugin:
$(document).on('contextmenu','#object_id',function() {
//code
});
I think you must use enableContextMenuItems() method on the newly added elements. If you post your code it would be easier to help.
精彩评论