You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Attila Tarkabak <ta...@gmail.com> on 2013/10/21 13:01:17 UTC
Wicket.Event.publish and bubbling
Hello List!
I can see that Wicket 6 is using jQuery.triggerHandler() for propagating
events like '/dom/node/removing' or '/dom/node/added', which occur when an
AJAX response is processed. Is there a particular reason for not using
jQuery.trigger() instead?
jQuery.triggerHandler() does not make events bubble up the DOM tree, which
seems counter intuitive with the aforementioned two events. If these events
bubbled, custom JavaScript could listen to them on the <body> and trace
them back to their source using the 'target' property. This would help when
attempting to attach / detach JavaScript instances from elements that are
being replaced.
Would it be possible to replace the calls in Wicket.Event.publish() and use
jQuery.trigger() in place of jQuery.triggerHandler()? I think it would make
the life of JavaScript widget developers - meaning yours truly - easier.
Cases I am especially concerned about:
<div id="A">
<p id="B">Foo</p>
</div>
Let's say I have a custom JavaScript widget attached to "B". If "A" is
replaced, there's no way the widget can be notified, unless it can listen
to '/dom/node/removing' on the <body> and detect that the event.target is a
parent of "A". Then it can detach itself before the replace occurs.
If you have any suggestions on solving this problem with the current setup,
I am interested.
Best regards,
Attila
Re: Wicket.Event.publish and bubbling
Posted by Attila Tarkabak <ta...@gmail.com>.
Hi Martin,
You are very right, I have mistaken the element. Thank you for your quick
answer!
Best regards,
A
On Mon, Oct 21, 2013 at 1:27 PM, Martin Grigorov <mg...@apache.org>wrote:
> Hi,
>
>
>
>
> On Mon, Oct 21, 2013 at 2:01 PM, Attila Tarkabak <tarkabak1@gmail.com
> >wrote:
>
> > Hello List!
> >
> > I can see that Wicket 6 is using jQuery.triggerHandler() for propagating
> > events like '/dom/node/removing' or '/dom/node/added', which occur when
> an
> > AJAX response is processed. Is there a particular reason for not using
> > jQuery.trigger() instead?
> >
> > jQuery.triggerHandler() does not make events bubble up the DOM tree,
> which
> > seems counter intuitive with the aforementioned two events. If these
> events
> > bubbled, custom JavaScript could listen to them on the <body> and trace
> >
>
> Wicket uses jQuery(**document**).triggerHandler().
> The event is not triggered on the added/removed element. This would make
> things slower for no benefit.
>
>
> > them back to their source using the 'target' property. This would help
> when
> > attempting to attach / detach JavaScript instances from elements that are
> > being replaced.
> >
>
> You can use Wicket global listeners to implement what you need.
>
>
> >
> > Would it be possible to replace the calls in Wicket.Event.publish() and
> use
> > jQuery.trigger() in place of jQuery.triggerHandler()? I think it would
> make
> > the life of JavaScript widget developers - meaning yours truly - easier.
> >
> > Cases I am especially concerned about:
> >
> > <div id="A">
> > <p id="B">Foo</p>
> > </div>
> >
> > Let's say I have a custom JavaScript widget attached to "B". If "A" is
> > replaced, there's no way the widget can be notified, unless it can listen
> > to '/dom/node/removing' on the <body> and detect that the event.target
> is a
> > parent of "A". Then it can detach itself before the replace occurs.
> >
> > If you have any suggestions on solving this problem with the current
> setup,
> > I am interested.
> >
> > Best regards,
> > Attila
> >
>
Re: Wicket.Event.publish and bubbling
Posted by Martin Grigorov <mg...@apache.org>.
Hi,
On Mon, Oct 21, 2013 at 2:01 PM, Attila Tarkabak <ta...@gmail.com>wrote:
> Hello List!
>
> I can see that Wicket 6 is using jQuery.triggerHandler() for propagating
> events like '/dom/node/removing' or '/dom/node/added', which occur when an
> AJAX response is processed. Is there a particular reason for not using
> jQuery.trigger() instead?
>
> jQuery.triggerHandler() does not make events bubble up the DOM tree, which
> seems counter intuitive with the aforementioned two events. If these events
> bubbled, custom JavaScript could listen to them on the <body> and trace
>
Wicket uses jQuery(**document**).triggerHandler().
The event is not triggered on the added/removed element. This would make
things slower for no benefit.
> them back to their source using the 'target' property. This would help when
> attempting to attach / detach JavaScript instances from elements that are
> being replaced.
>
You can use Wicket global listeners to implement what you need.
>
> Would it be possible to replace the calls in Wicket.Event.publish() and use
> jQuery.trigger() in place of jQuery.triggerHandler()? I think it would make
> the life of JavaScript widget developers - meaning yours truly - easier.
>
> Cases I am especially concerned about:
>
> <div id="A">
> <p id="B">Foo</p>
> </div>
>
> Let's say I have a custom JavaScript widget attached to "B". If "A" is
> replaced, there's no way the widget can be notified, unless it can listen
> to '/dom/node/removing' on the <body> and detect that the event.target is a
> parent of "A". Then it can detach itself before the replace occurs.
>
> If you have any suggestions on solving this problem with the current setup,
> I am interested.
>
> Best regards,
> Attila
>