Using a function in jquery contextMenu selector -


below example https://github.com/medialize/jquery-contextmenu.

what need put function in "selector:" use bunch of logic make decision on element candidacy.

any suggestions?

$(function(){     $.contextmenu({         selector: '.context-menu-one',          callback: function(key, options) {             var m = "clicked: " + key;             window.console && console.log(m) || alert(m);          },         items: {             "edit": {name: "edit", icon: "edit"},             "cut": {name: "cut", icon: "cut"},             "copy": {name: "copy", icon: "copy"},             "paste": {name: "paste", icon: "paste"},             "delete": {name: "delete", icon: "delete"},             "sep1": "---------",             "quit": {name: "quit", icon: "quit"}         }     });      $('.context-menu-one').on('click', function(e){         console.log('clicked', this);     }) }); 

try that:

setcontextmenu: function () {     $.contextmenu({         selector: '.datatable tbody tr',         build: function ($trigger, e) {             // callback executed every time menu shown             // results destroyed every time menu hidden             // e original contextmenu event, containing e.pagex , e.pagey (amongst other data)             return {                 callback: function (key, options) {                     var obj = eval("(" + $(this).attr("valor") + ")");                      if (key == "editar") {                         console                     }                      if (key == "visualizar") {                      }                 },                 items: {                     "sep1": "---------",                     "editar": { name: "editar", style: "ui-icon-document" },                     "sep2": "---------",                     "visualizar": { name: "visualizar", style: "ui-icon-closethick" },                     "sep3": "---------",                 }             };         }     }); } 

Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -