2

I have an asynchronous easyui tree,in which a function is called on click of each node. When a node is clicked,data corresponding to that node will be populated.I want to prevent the click of another node,while data is being populated for one node. This is my code for tree:

<ul id="jqueryTree" class="easyui-tree" data-options="animate:true,lines:true">  
</ul> 

$('#jqueryTree').tree({
onClick: function(node){
    populateData(node.id);
}

}); 

And I tried like this:

$('#jqueryTree').off('click');
$('#jqueryTree').on('click');

But no luck :(

user1934095
  • 103
  • 2
  • 13
  • You can use "return false" to disable the default event to happen: http://stackoverflow.com/questions/128923/whats-the-effect-of-adding-return-false-to-an-onclick-event – Jon Jul 16 '13 at 05:47
  • I tried that...but the node selected for the second time,becomes selected node and highlighted.So it looks like,one node is selected and data for some other node is populated. – user1934095 Jul 16 '13 at 05:53

1 Answers1

2

Try like this,

var flag=true;
$('#jqueryTree').tree({
 onClick: function(node){
   $('#jqueryTree').tree('select', node);    
 },
onSelect:function(node)
{
  if(flag)
  {
    flag=false;
    populateData(node.id);
  }
},
onBeforeSelect:function(node)
{
  if(!flag) return false;
}
}); 

function populateData(id)
{
 // your stuff
flag=true;
}
Saigitha Vijay
  • 466
  • 3
  • 8