0
這是我的代碼,我將右鍵單擊一個節點並顯示一個對話框,然後我將選中此對話框中的複選框以隱藏此節點。但是,似乎每當我右鍵單擊多個節點(不勾選前一節點的複選框,而是選中當前節點的複選框)時,它會隱藏所有先前右鍵單擊的節點,而不是僅隱藏當前右鍵單擊的節點,點擊一個。 這裏是代碼:event.cyTarget堅持以前的事件
cy.on('cxttap','node',function(e) {
var target = e.cyTarget;
//after clicking node, display dialog, where a checkbox is shown.
$("#dialog-rightClick").dialog({
width:250,
title:target.id(),
position:{my: 'left',at: 'right',of:e}
});
//checkbox, if checked, hide the node, otherwise,show all nodes
$('#hdNode').change(function(){
if(this.checked){
// for (var i=0;i<target.length;i++)
//{
// console.log(target[i].data());
// }
target.hide();
}
else{
target.show();
}
});
有人幫我嗎?非常感謝
如果測試e。在調用$(「#dialog-rightClick」)。dialog()之前調用cyTarget。它會起作用,但$('#hdNode')。change(function(){}中的target.hide()會堅持前一個事件。 – LEON
如果沒有對話框,你可以證實嗎?否則,這幾乎肯定是對話框問題 – maxkfranz
解決我的問題,如果我在cy.on函數循環之前聲明var目標。 – LEON