2013-04-04 66 views
0

我正在嘗試jquery上下文菜單。它的工作正常。我的代碼如下如何停止jQuery的上下文菜單時div是空的?

$(function() { 
          $.contextMenu({ 
           selector: '.droppable', 
           callback: function (key, options) { 
            if (key == "delete") { 
             if ($(this).html() != "") { 
              $(this).html(""); 
              deleteKey($(this).attr("id")); 
             } 
            } 
           }, 
           items: { 
            "delete": { name: "Delete", icon: "delete" } 
           } 
          }); 


         }); 

現在我想不打開菜單時($(this).html()==「」)。

當容器的html爲空時,我可以防止菜單在右鍵點擊時打開嗎?

在此先感謝。

Vidhin

回答

0

OK,

我得到了孤子。

我需要運行一個代碼,每次當有在孔蒂

if ($(this).html() == "") { 
           $("#" + $(this).attr("id")).contextMenu(false); 
          } 

感謝的HTML變化。