Tom, thanks for detail explanation

On 1 окт, 21:34, Tom <[EMAIL PROTECTED]> wrote:
> buda,
>    Custom events work just like normal events (they're built on the
> dataavailable event) - so you watch for an event on a specific
> element.   For that event to be caught you need to fire it on the
> element you're listening on, or on a descendant of that element so
> that it bubbles up to the element you are observing on.  As I said
> before Hectors example shows one way of doing this
>
> $('Select1').observe('change', function()
> { $('Select2').fire('Select1:changed') });
>
> $('Select2').observe('Select1:changed', function()
> { alert('changed'); });
>
> here, you listen on Select1 for a change event, and when that is
> received you fire the Event "Select1:changed" on Select2, which is
> where you are listening for it, and the alert will be displayed.
> Obviously this method doesnt scale very well for multiple dependant
> selects and may not be the best solution.  Also in this case using
> custom events doesnt make a lot of sense since you could just do
> $('Select1').observe('change', function() { alert('changed'); }))
> and have the same behavior
>
> On Oct 1, 2:15 am, buda <[EMAIL PROTECTED]> wrote:
>
>
>
> > I'm disappointed
>
> > On 30 сент, 11:33, buda <[EMAIL PROTECTED]> wrote:
>
> > > You have definitively confused me - show how it would be right
>
> > > On 30 сент, 03:21, Tom <[EMAIL PROTECTED]> wrote:
>
> > > > Custom events are built on top of the dataavailable event, so they
> > > > behave just let any other standard bubbling event.   That means if you
> > > > want to be able to catch the event you need to be observing on an
> > > > element that it would bubble to.
> > > > In your code
> > > >   $('Select2').observe('Select1:changed', function()
> > > > { alert('changed'); });
> > > > it listens at the select2 event for your custom event named
> > > > "Select1:changed" - (note the name of the event is strictly arbitrary
> > > > and doesnt actually tie it in any way to Select1)  Because of this if
> > > > you fire the event on Select1 it will never bubble to Select2.  As
> > > > Hector pointed out if you fire the Event on select2 then your observer
> > > > will catch it - { $('Select2').fire('Select1:changed') }
>
> > > > Tom- Скрыть цитируемый текст -
>
> > > - Показать цитируемый текст -- Скрыть цитируемый текст -
>
> - Показать цитируемый текст -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to