Sagar Bandkar

Sagar Bandkar

  • NA
  • 347
  • 49.1k

Get Selected Menu Id of Context Menu Javascript

Feb 28 2017 7:36 AM
I want Id of Selected Menu id in callback which i inserted this  $.each(newArray, function (k, v) loop
 
var array = @Html.Raw(Json.Encode(@ViewBag.ShiftName));
for (var i = 0; i < array.length; i++) {
newArray.push({Text:array[i].Text,Value:array[i].Value});
}
$.contextMenu({
selector: '.context-menu-one',
className:"limit-context-size",
build: function ($trigger, e) {
var options = {
selector:newArray,
callback: function (key, options) {
alert(key);
alert(options.Text);
var tableRows = document.getElementById("datatable").rows;
for(var i = 1;i<= selday.length; i++) {
myRowIndex = $(this).parent().index();
myColIndex = $(this).index();
//myRowIndex = selday[i].parent().index();
//myColIndex = selday[i].index();
alert(myRowIndex);
alert(myColIndex);
var tds = tableRows[myRowIndex].cells;
tds[myColIndex].innerHTML += "-"+key
}
alert("Clicked on " + key + " on element " + options.$trigger.attr("id"));
return true;
},
items: {
}
};
$.each(newArray, function (k, v) {
options.items[v.Text] = {
name:v.Text,
id:v.Value
};
});
return options;
}
});

Answers (2)