[ 2 posts ]

Fedor

  • Username: ted
  • Joined: Wed Mar 16, 2011 11:25 pm
  • Posts: 4
  • Offline
  • Profile

Broadcasting <attribute>Change events - undesired behaviour

Post Posted: Thu Mar 31, 2011 9:38 pm
+0-
Hi everyone!
I stumbled upon a strange behaviour. YUI pros, tell me whether this OK or I am doing something wrong.


I have a widget with a bunch of attributes. Some of them have the 'broadcast' property set to '1'. The problem is, when I set a global listener to the broadcasted attribute, this listener is unable to prevent the attribute from being set. All it can do is to prevent the 'afterChange' listeners.

Here is the test code: http://jsbin.com/oqehi5/edit (turn on your console).

As you can see, when the listener calls e.preventDefault(), the attribute is already set.

So, is there a way to fix it?

Luke Smith

YUI Contributor

  • Username: lsmith
  • Joined: Thu Aug 28, 2008 7:50 am
  • Posts: 509
  • Location: Sunnyvale
  • Twitter: ls_n
  • GitHub: lsmith
  • Gists: lsmith
  • IRC: ls_n
  • YUI Developer
  • Offline
  • Profile

Re: Broadcasting <attribute>Change events - undesired behavi

Post Posted: Fri Apr 01, 2011 9:49 am
+1-
The broadcast system is separate from the bubbling system. If you configure your objects to bubble to Y via myObject.addTarget(Y); then you can prevent the events. Broadcasted events aren't preventable.
  [ 2 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