Here's the situation: I have a dynamic system that handles div ids. I successfully took control of the context menu with my own script, but it only works if the element id is hardcoded. I've been attempting to create a function that retrieves the element name from an array list, but it keeps throwing errors all over the place.
function menuclick()
{
alert("Menuclick Called");
var limen= ["armenu", "ormenu", "prmenu", "apmenu", "auxmenu", "itmenu", "sysmenu"];
var menues= Array();
var men1 = "menu$pf1$topmen$topmen$menul$menuli$";
for (idx=0;idx<6;idx++){
menues[idx] = "#"+men1+limen[idx];
$(menues[idx]).bind("contextmenu", this.id, function(e) {
$('#example-menu').css({
top: e.pageY+'px',
left: e.pageX+'px'
}).show();
return false;
});
alert(menues[idx]);
}
return;
}
The issue seems to revolve around $(menues[idx]).bind, specifically the menues[idx] part. I just can't seem to pinpoint why it's causing trouble. Any suggestions?
EDIT ** I forgot to mention, the error message displayed by Firebug reads:
"Uncaught exception: Syntax error, unrecognized expression: $pf1$topmen$topmen$menul$menuli$armenu"
EDIT** It's worth noting that php is used to fetch the div ids from a database.