Perfect, it works. Thanks!
On Thu, Apr 26, 2012 at 3:52 PM, Martin Grigorov <mgrigo...@apache.org> wrote: > Hi, > > All you need is #renderHead() that does: > response.render(OnDomReadyHeaderItem.forScript(getInitJavaScript()) > > initJS will be delivered to the page after each re-render of the > component - both Ajax and non-Ajax. > > On Thu, Apr 26, 2012 at 4:46 PM, Jordi Deu-Pons <jo...@jordeu.net> wrote: >> Hi, >> >> I'm developing a component that needs to call a javascript function >> after it's rendered (throw and AJAX update or a normal request). >> >> I get it running like this: >> >> @Override >> protected void onBeforeRender() { >> super.onBeforeRender(); >> AjaxRequestTarget target = >> RequestCycle.get().find(AjaxRequestTarget.class); >> if (target != null) { >> target.appendJavaScript( getInitJavaScript() ); >> } >> } >> >> @Override >> public void renderHead(IHeaderResponse response) { >> response.render(JavaScriptHeaderItem.forScript( >> "Wicket.Event.add(window, \"load\", function(event) { >> " + getInitJavaScript() + " });", >> "load-codemirror-js") >> ); >> } >> >> But, Is there a better way? >> >> Thanks! >> >> -- >> a10! i fins aviat. >> J:-Deu >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org >> For additional commands, e-mail: users-h...@wicket.apache.org >> > > > > -- > Martin Grigorov > jWeekend > Training, Consulting, Development > http://jWeekend.com > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > -- a10! i fins aviat. J:-Deu --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org