0

This is my code,I will right click one node and a dialog will display, and then I will check the checkbox in this dialog to hide this one. However, it seems every time when I right click more than one node (not check the checkbox for previous node but check the checkbox of current node), it will hide all of previously right-clicked ones instead of only hiding the current right-clicked one. Here is the code:

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();
      }
    });

Is there someone help me out? Thanks very much

LEON
  • 73
  • 2
  • 9

1 Answers1

0

I have written tests to confirm that events including cxttap do indeed put the proper e.cyTarget for successive triggers. If you confirm there is an error on the cy.js side -- rather than elsewhere in the code of your system -- please file an issue with a brief bit of code that reproduces the error: https://github.com/cytoscape/cytoscape.js/issues/new

maxkfranz
  • 11,896
  • 1
  • 27
  • 36
  • if you test e.cyTarget before you call $("#dialog-rightClick").dialog(). it will works, but the target.hide() in in $('#hdNode').change(function(){} will stick to previous event. – LEON Oct 02 '13 at 15:53
  • Can you confirm this without the dialog? Otherwise, this is almost certainly a dialog issue. – maxkfranz Oct 10 '13 at 14:58
  • solve my problem, if I declare var target before the cy.on function loop. – LEON Oct 18 '13 at 15:59