Through this article to introduce the Smart right button menu, need to introduce the file will be given at the end of the text, first show you the code:
The specific code looks like this:
var cityarray = new Array ();
Cityarray.push ("Beijing");
Cityarray.push ("Shanghai");
Sets the table header's Mouse right-click event $ (' th '). MouseDown (function (e) {var selected = e.target.innerhtml;
3 represents the right key if (e.which==3) {if (selected== "booking type") {var opertion ={name: "Booking Type"};
var data = [[{text: ' Out of ticket ', Func:function () {alert ("Out of ticket ');"
}],[{text: ' Leave a ticket ', func:function () {alert ("Leave the Ticket");
}],[{text: ' Change sign ', func:function () {alert ("change");
}],[{text: ' Refund ', func:function () {alert ("refund");
}}],[{text: ' All ', func:function () {alert ("all");
}
}]];
$ (this). Smartmenu (data,opertion);
}else if (selected== "departure city") {var opertion ={name: "Departure City"};
var data = [];
for (Var i=0;i<cityarray.length;i++) {//Use closures (function (i) {func = function () {alert (cityarray[i));
}) (i);
var obj = {Text:cityarray[i], func:func};
var cArray = new Array ();
Carray.push (obj);
Data.push (CArray);
var other = {text: all, func:function () {alert ("all");
} var Otherarray = new Array (); Otherarray.push (other);
Data.push (Otherarray);
$ (this). Smartmenu (data,opertion); } return false;//block link jump});
$ (' th ') specifies the label with the right key, according to the actual to determine that I am here added to the table header, so is th label
E.which = 3 is the right key
Two things are listed here
One is the content on the menu. Determines the name of the right-click menu with the previous opertion, to be unique
The other is not sure you can get the data from the server, stored in the array, I wrote here dead, and then implemented in a second way it requires a closure
Files to introduce: http://download.csdn.net/detail/u012116457/9449905
The above content is small make up for everyone to share based on JavaScript implementation of Intelligent right menu of knowledge, hope to help everyone!