You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by EC James <ja...@canada.ca> on 2015/11/19 22:44:15 UTC

Event listeners not working after Javascript actions

I have a page with a Tabbed interface(not wicket) that performs actions
before and after the domready signal.

It has it's own signal for when it is complete:
$( document ).on( "wb-ready.wb", function( event ) {
	//The page is fully loaded now.
}

The rendering order is like this:
1) Tab 1 rendered
2) Page loaded (domready)
3) Tab 1 rendered
4) Done loading (wb-ready.wb)

I have an AjaxButton in Tab 1 that does not work. It works fine outside the
tab.

I'm guessing that something is happening in the 3rd stage that removes the
event listener.

As a test, if I take the following from the header and put it in the
"wb-ready.wb" all is good. Of course this only
works as a test as I have to manually change the url.
/**/

I have no idea how to fix this. All I can imagine is:
1) Somehow rerunning Wicket.Event.add after "wb-ready.wb", or
2) Moving Wicket.Event.add out of the head and into "wb-ready.wb", which I
don't think is possible.

Any ideas on how to reregister the event listener for the button?

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Event-listeners-not-working-after-Javascript-actions-tp4672673.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Event listeners not working after Javascript actions

Posted by EC James <ja...@canada.ca>.
Thanks for the clone idea, however it seems that AjaxButton cannot be cloned.
I did try a similar idea,
where I define the tab content outside of the tab, and only move it into the
tab using '.replaceWith'
when the page is fully loaded.  This works but makes for some ugly
transitions.

The tabbed interface is a third party plugin, and I don't know why it is
re-rendering the content. I will 
have to look into that.

It would be nice if I could decide when the events are loaded instead of on
'domready', but I don't see 
any easy way to do that.

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Event-listeners-not-working-after-Javascript-actions-tp4672673p4672764.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Event listeners not working after Javascript actions

Posted by Martin Grigorov <mg...@apache.org>.
Hi,


On Thu, Nov 19, 2015 at 10:44 PM, EC James <ja...@canada.ca> wrote:

> I have a page with a Tabbed interface(not wicket) that performs actions
> before and after the domready signal.
>
> It has it's own signal for when it is complete:
> $( document ).on( "wb-ready.wb", function( event ) {
>         //The page is fully loaded now.
> }
>
> The rendering order is like this:
> 1) Tab 1 rendered
> 2) Page loaded (domready)
> 3) Tab 1 rendered
> 4) Done loading (wb-ready.wb)
>
> I have an AjaxButton in Tab 1 that does not work. It works fine outside the
> tab.
>
> I'm guessing that something is happening in the 3rd stage that removes the
> event listener.
>

Yes. If you re-render the tab's content then you replace the original DOM
element for the button and thus you lose its event listener.
Why do you need to re-render the content?
Is it OK for you if you preserve the button? You can use jQuery.clone(true,
true) to make a clone that preserves the event listeners and put this clone
after the re-render.


>
> As a test, if I take the following from the header and put it in the
> "wb-ready.wb" all is good. Of course this only
> works as a test as I have to manually change the url.
> /**/
>
> I have no idea how to fix this. All I can imagine is:
> 1) Somehow rerunning Wicket.Event.add after "wb-ready.wb", or
> 2) Moving Wicket.Event.add out of the head and into "wb-ready.wb", which I
> don't think is possible.
>
> Any ideas on how to reregister the event listener for the button?
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Event-listeners-not-working-after-Javascript-actions-tp4672673.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>