开发者

jquery contextMenu + .live

开发者 https://www.devze.com 2023-03-22 04:25 出处:网络
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

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.

0

精彩评论

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