You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Graeme Knight <gr...@gmail.com> on 2008/12/07 23:25:24 UTC

Calling Javascript on AJAX load of panel.

Hi.

I have  a panel that loads different content depending on a context (i.e.
clicking on a tab moves it to another view, etc).

One of the views is an iframe which will have content populated by
Javascript. 

I have something like this as a header contributor, which populates 'hello
world' into the iframe:

        IModel variablesModel = new AbstractReadOnlyModel()
        {
            private static final long serialVersionUID =
-4744542904096678956L;

            public Map getObject()
            {
                Map< String, CharSequence > variables = new HashMap< String,
CharSequence >();
                
                variables.put( "originalContent", "Hello world" );
                
                return variables;
            }
        };

        add( TextTemplateHeaderContributor.forJavaScript(
TextReadPanel.class, "IFrameLoader.js", variablesModel ) );

Two questions:

1) Is the header contributor added to the html (this is ajax so there is no
page refresh).
2) How to call the function in IFrameLoader.js (initializeIFrame()) AFTER
the iframe has rendered?

Perhaps the above is the wrong way to do the following:

1) User clicks on tab.
2) Panel is switched into text reading 'context'.
3) IFrame is rendered, innerHTML of iframe is populated through the
initializeIFrame() Javascript function (rendering originalContent).

Does this sound plausible in Wicket?

Many thanks, Graeme.
-- 
View this message in context: http://www.nabble.com/Calling-Javascript-on-AJAX-load-of-panel.-tp20886721p20886721.html
Sent from the Wicket - User 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: Calling Javascript on AJAX load of panel.

Posted by Timo Rantalaiho <Ti...@ri.fi>.
On Sun, 07 Dec 2008, Graeme Knight wrote:
> 1) Is the header contributor added to the html (this is ajax so there is no
> page refresh).

I think so, just look at the page source e.g. with Firebug?

> 2) How to call the function in IFrameLoader.js (initializeIFrame()) AFTER
> the iframe has rendered?

You mean after rendering it with Ajax? You can probably just 
put the call in HTML, if you want it executed on each render.
Or for just Ajax repaints, use AjaxRequestTarget.appendJavaScript().

> Perhaps the above is the wrong way to do the following:
> 
> 1) User clicks on tab.
> 2) Panel is switched into text reading 'context'.
> 3) IFrame is rendered, innerHTML of iframe is populated through the
> initializeIFrame() Javascript function (rendering originalContent).
> 
> Does this sound plausible in Wicket?

Frankly I don't really get what you're trying to achieve.
Maybe you could use TabbedPanel or AjaxTabbedPanel?

Best wishes,
Timo


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