Create a li context menu with Bootstrap
I found a way to make a cool context menu on this question . I am trying to add this functionality to a dynamic li that I have created. Unfortunately this doesn't work.
This is the code to launch the context menu. It works great for normal li.
$("#myTab li").contextMenu({
menuSelector: "#contextMenu",
menuSelected: function (invokedOn, selectedMenu) {
var msg = "You selected the menu item '";
alert(msg);
}
})
;
But when I tried to click dynamically, the newly created one doesn't work. I thought this would work, but it looks like I am wrong. I have this demo showing how it should work: http://jsbin.com/qonuy/6 How to use event delegation for these cases? Thanks to
$(document).on('contextMenu','"#myTab li',function(event){
menuSelector: "#contextMenu",
menuSelected: function (invokedOn, selectedMenu) {
var msg = "You selected the menu item '";
alert(msg);
}
});
+3
source to share
No one has answered this question yet
See similar questions:
or similar: