3

I found a way to make cool context menu on this question. I'm trying to add this functionality on dynamic li I have created. Unfortunately this isn't working.

This is the code for running the context menu. It works fine 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 to the dynamic li just created it doesn't work. I thought this way will work, but it looks I'm wrong . I have this demo showing how it suppose to work: http://jsbin.com/qonuy/6 How do I use event delegation for this cases? Thanks

$(document).on('contextMenu','"#myTab li',function(event){
  menuSelector: "#contextMenu",
    menuSelected: function (invokedOn, selectedMenu) {
        var msg = "You selected the menu item '";
        alert(msg);
    }
});
Community
  • 1
  • 1
Diego
  • 916
  • 1
  • 13
  • 36

0 Answers0