I have a javascript file that creates a contextual menu.
function textCM()
{
$('.text').contextMenu('context-menu-1', {
'Context Menu Item 1 node level 1': {
click: function(element){ printId(element.attr('id')); },
},
'Context Menu Item 2 node level 1': {
click: function(element){ printId(element.attr('id')); },
},
});
}
I am trying to make the function create the context menu dynamicly (send a list of parameters and add them in my function). What I have did untill now looks something like this:
function textCM()
{
$('.' + arguments[0]).contextMenu('context-menu-1', {
arguments[1]: {
click: function(element) {
alert('Menu item 1 clicked' + element.attr('id'));
},
},
});
}
The first function works as expected, but in the second function I get an error
SyntaxError: missing : after property id
that is caused by the line
arguments[1]: {
I know there are other questions with same error, but, as far as I can tell, it's not the same problem. I just can't seem to understand what I am doing wrong.