2
我使用jquery contextmenu plugin菜單,這裏是我的DEMOjQuery的文本菜單 - 如何使用文本菜單操作來獲取點擊的項目的ID在
下面是我的代碼:
<script type="text/javascript">
$(function() {
$.contextMenu({
selector: '.context-menu-one',
callback: function (key, options) {
var m = "clicked: " + key;
window.console && console.log(m) || alert(m);
alert("Clicked on " + key + " on element " + options.$trigger.attr('id').substr(3));
},
items: {
"edit": { "name": "Edit", "icon": "edit" },
"fold1": {
"name": "Apply for Section",
"items": {
"Section I": { "name": "Section I" },
"Section II": { "name": "Section II" },
"Section III": { "name": "Section III" }
}
},
"fold2": {
"name": "Sub group",
"items": {
"fold1-key1": { "name": "Foo bar" },
"fold2": {
"name": "Sub group 2",
"items": {
"fold2-key1": { "name": "Sub group 1" },
"fold2-key2": { "name": "Sub group 2" },
"fold2-key3": { "name": "Sub group 3" }
}
},
"fold1-key3": { "name": "delta" }
}
},
"fold1a": {
"name": "Other group",
"items": {
"fold1a-key1": { "name": "Other group1" },
"fold1a-key2": { "name": "Other group2" },
"fold1a-key3": { "name": "Other group3" }
} } } }); });
cshtml頁面
@foreach(var id in data)
{
<div class="context-menu-one">
<input type="hidden" id="txtID" value="@id">
</div>
<br/>
}
使用文本菜單
問題
1)我想txtID
當我點擊任何菜單上從文本菜單,因爲它id
幫助我瞭解數據庫哪一行更新?
2)我有三個表Section
Sub group
Other group
所以當點擊部分更新Section
表中的數據庫與其他兩個表相同時。我想要獲得從Section
或Sub group
或Other group
中點擊哪個子菜單,那麼如何獲取它?