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 <[email protected]> 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: [email protected]
> For additional commands, e-mail: [email protected]
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to