EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: kavvson on October 14, 2014, 10:14:52 AM



Title: e.preventDefault(); in tree node?
Post by: kavvson on October 14, 2014, 10:14:52 AM
 
Code:
onClick: function(node){
alert(node.text);  // alert node text property when clicked

$.get(
$(this).attr('href'),
function(data) {
  $('#te').html(data);
  }
);

}

I got such code, and I wan't to disable in the node the <a> tag - normally it works with  e.preventDefault(); but it seems like it can't be added here.

Its because I have a formatter for the tree

Code:
if (node.text > 0){ return '<a class=clicker href=logs/'+node.text+'/' + node.text + '.log>' + node.text + '</a>';}


Title: Re: e.preventDefault(); in tree node?
Post by: chrwei on October 14, 2014, 12:37:05 PM
the onClick is on what, exactly?


Title: Re: e.preventDefault(); in tree node?
Post by: kavvson on October 15, 2014, 03:28:39 AM
Onclick the node text that was been created with <a href> it would load the data into my textarea ( its a .log reader )


Title: Re: e.preventDefault(); in tree node?
Post by: chrwei on October 15, 2014, 07:09:04 AM
of the <a> is inside the element that the onClick on, the the <a>'s own onlick will complete before that handler. 


Title: Re: e.preventDefault(); in tree node?
Post by: kavvson on October 15, 2014, 09:09:43 AM
so how could I handle it?


Title: Re: e.preventDefault(); in tree node?
Post by: chrwei on October 15, 2014, 12:37:39 PM
don't put the href to the file, instead have your onlick handle it. 


Title: Re: e.preventDefault(); in tree node?
Post by: kavvson on October 15, 2014, 01:01:22 PM
Looking on the above code. What would it be and now to call in the tag the onclick trigger


Title: Re: e.preventDefault(); in tree node?
Post by: chrwei on October 15, 2014, 01:04:59 PM
the above code is incomplete.  I can only speculate to what your actual issue is.  I don't know where they values come from, or even where they are going to.  I will say that if you want handle on the onClick, then handle it on that onClick. where you keep the values and get the data from is something that can be done a dozen ways.