2014-01-10 40 views
2

我想基於右鍵單擊的DOM元素的ID創建動態菜單。這樣我就可以顯示特定用戶如菜單「標籤23」基於右鍵單擊的DOM元素的ID創建動態菜單

我使用的上下文菜單這樣的事情,

$.contextMenu({ 
      selector: 'tr', 
      callback: function (key, options) { 
       var m = "clicked: " + key; 
       var temp = $(this); 
       if (key == "Rebate") DoInvoice(); 
      }, 
      items: { 
       "Credit Note": { name: "Credit Note " }, 
      "Full Refund": { name: "Full Refund " }, 
      "Partial Refund": { name: "Partial Refund " }, 
      "Rebate": { name: "Rebate " } 
       } 
      }); 

目前我正在上點擊右鍵快捷菜單如圖所示在下面的圖片, enter image description here

但我要表明,在格式像

"Credit Note For 130", 
"Full Refund For 130", 
"Partial Refund For 130", 
"Rebate For 130" 

請幫我在這 儘快。

回答

0

試試這個: -

var userid; 
// Get the ID, when rightclick event is fired & set the ID to above variable. 

items: { 
       "Credit Note For"+ userid : { name: "Credit Note " }, 
      "Full Refund For"+ userid : { name: "Full Refund " }, 
      "Partial Refund For"+ userid : { name: "Partial Refund " }, 
      "Rebate For"+ userid : { name: "Rebate " } 
       } 
+0

它不工作。 我想使用背景中的'ID',而不是這種。 – Rahul

+0

查看編輯答案。 – Anup

+0

這不起作用, 您給出的代碼會引發異常。 – Rahul