I' m trying to use jQuery contextMenu within a joomla 3 site. The basic jquery code for the menu is:
$(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: function(){
return 'context-menu-icon context-menu-icon-quit';
}}
}
});
I load jquery framework with JHtml::_('jquery.framework');
I replaced $function
with jQuery(function(){
.
How may I change $.contextMenu so that it is acceptable by Joomla? I tried many changes but I get $.contextMenu is not a function.
I also tried to use JHtml::_('jquery.framework',false);
so that to use $ instead of (jQuery) but still not acceptable.
If I include jquery library from a cdn and use $ instead of (jQuery) it works fine but this way I' m getting conflicts with other extensions that use jquery.
jQuery(function(){
withjQuery(function($){
.