Hi!

You can override #onEvent in your “parent” component.

The AjaxRequestTarget is broadcast as an event (you can check if the
payload is an ART).


You can then check if the ART contains your table component, and if it
does, append your javascript.

Met vriendelijke groet,
Kind regards,

Bas Gooren

Op 22 december 2016 bij 15:40:23, MissOvenMitts (
chantal.lucette.da...@gmail.com) schreef:

Thank you guys so much for your quick responses!

I had not tried global listeners - mostly because if I have a component and
not a target (as one of the method parameters) I don't really get how to
call a javascript function. For example, when I have a target, I can do a
target.appendJavaScript()....

target.appendJavaScript("alert('You clicked a button!')"); br/> <
... and that runs immediately. I guess with this example I'm not sure where
to put the javascript, is my point.

So, for more detail on what I'm trying to do:

It is, in fact, the same exact Javascript that needs to be run for every
button/link in the data table (in addition to the function the buttons
already perform, obviously, like paging).

At the moment I have a behavior attached to a random WebMarkupContainer on
the base page where the datatable is (the datatable is not a child of the
WebMarkupContainer.. this is just the only way I really know how to add
javascript into the header and into the onDomReady). br/> <
This behavior simply renders javascript to the header for the javascript
function that I want to use called myTableFunction.

Then the behavior simply adds the following javascript on Dom Ready:

("$(\"html\").find(\".mySpecialTableClass\").myTableFunction({'left' : 1,
'foot' : true, 'head' : true});");

This javascript just searches the page for a particular class and runs a
javascript function on it.

The javascript doesn't need the wicket's Component ID, and the behavior
that
creates the javascript isn't even attached to the wicket table which
receives the changes from the javascript.

So, as it stands, the javascript function is called when the page loads up
and everything works perfectly. However, obviously, whenever any paging
links in the .mySpecialTableClass data-table are clicked, the table is
refreshed and the changes that the javascript myTableFunction() made on the
table naturally disappear. br/> <
As a result, we want to tack the same javascript we already put onDomReady
onto any other clicks within the data table that might refresh it.

I hope that makes more sense!

Again, your help is so appreciated. This has been one of those changes that
has you pacing outside wanting to tear your hair out. It's *so* close to
completion that it's that much more frustrating.





-- 
View this message in context:
http://apache-wicket.1842946.n4.nabble.com/Calling-Javascript-for-any-event-in-a-parent-tp4676501p4676510.html
Sent from the Users forum mailing list archive at Nabble.com.

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

Reply via email to