[ 5 posts ]

rmjrao

  • Username: rmjrao
  • Joined: Tue Jul 17, 2012 11:35 pm
  • Posts: 7
  • IRC: rao
  • Offline
  • Profile

How to stop collapsing tree node on click event?

Post Posted: Tue Jul 17, 2012 11:48 pm
+0-
Hi,

I am usning treeview and try to stop collapsing feature on click event.I want to implement the collapse or expand for double click and not for single click.
My code is prety much like http://developer.yahoo.com/yui/examples ... _tree.html

I appriciate your help.

Thanks,
rmj.

Satyam

YUI Contributor

  • Username: Satyam
  • Joined: Tue Dec 09, 2008 12:34 am
  • Posts: 2016
  • Location: Sitges, Spain
  • GitHub: Satyam
  • Gists: Satyam
  • IRC: DevaSatyam
  • YUI Developer
  • Offline
  • Profile
Tags:

Re: How to stop collapsing tree node on click event?

Post Posted: Wed Jul 18, 2012 12:22 pm
+0-
Plain click is hardwired to toggling when done on the plus/minus sign. That you cannot change.

However, you can listen to click event, do whatever you want in response to it and return false (just as with regular DOM events) to prevent toggling. Then you can set up an event listener for double click and call node.toggle yourself.

This would be weird: simple clicking on the toggle icon but double clicking on the label.

Using double click might not be a good idea for another reason: it will slow down every click listener. When there is a double click, browsers will emit two click events first. TreeView solves it by checking if anyone has subscribed to double-click. If no one has, then every click is passed through. If someone is listening to double click, on the first click it will keep quiet about it and launch a timer. If no click happens before a timeout, it assumes it wasn't a double click and responds to that first click. If a second click happens, then it fires the double click event. However, for any regular click, it will delay until it is sure it is not double. So, if you can avoid it, don't use double click.

rmjrao

  • Username: rmjrao
  • Joined: Tue Jul 17, 2012 11:35 pm
  • Posts: 7
  • IRC: rao
  • Offline
  • Profile
Tags:

Re: How to stop collapsing tree node on click event?

Post Posted: Wed Jul 18, 2012 4:21 pm
+0-
Thank you very much for quick reply.
I tried following code and it's not working

tree.subscribe("clickEvent", function(node) {
return;
});
am doing something wrong here?

Thanks,
Murali.

Satyam

YUI Contributor

  • Username: Satyam
  • Joined: Tue Dec 09, 2008 12:34 am
  • Posts: 2016
  • Location: Sitges, Spain
  • GitHub: Satyam
  • Gists: Satyam
  • IRC: DevaSatyam
  • YUI Developer
  • Offline
  • Profile

Re: How to stop collapsing tree node on click event?

Post Posted: Thu Jul 19, 2012 7:06 am
+0-
How about "return false" as I said? Returning undefined is not the same as returning false.

rmjrao

  • Username: rmjrao
  • Joined: Tue Jul 17, 2012 11:35 pm
  • Posts: 7
  • IRC: rao
  • Offline
  • Profile
Tags:

Re: How to stop collapsing tree node on click event?

Post Posted: Thu Jul 19, 2012 10:11 am
+0-
Thank you very much.
"return false" is working.

Thanks,
rmjrao.
  [ 5 posts ]
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum