You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by thomas jaeckle <ma...@gmail.com> on 2007/12/20 08:44:18 UTC

Problem with JavaScript when using Wicket AJAX Components

Hi there.

I wanted to implement Tooltips for my DataTable as described in the Wiki: 
http://cwiki.apache.org/WICKET/how-to-add-tooltips.html

So in every page I want to use them I add this in the page constructor:
add(HeaderContributor.forCss(AbstractBorder.class,
"resource/css/sweetTitles.css"));
add(HeaderContributor.forJavaScript(AbstractBorder.class,
"resource/js/addEvent.js"));
add(HeaderContributor.forJavaScript(AbstractBorder.class,
"resource/js/sweetTitles.js"));

The sweetTitles tooltips are working if I add the DataTable directly to the
page.
But they are not working for the table when I use a "AjaxLazyLoadPanel"
around the DataTable (for other Components on the Page that are outside the
AjaxLazyLoadPanel they are still working).

Or at another place I use a "LinkTree" and change a panel when it is clicked
on a node. I also added the "add(HeaderContributor ...." stuff for the
WebPage with the LinkTree, but in the Panels I can't use the sweetTitles
tooltips.

When I look at the generated HTML-Code the JavaScript-Files are always
correctly in the header.
But why are they not working?

Any idea? Did I miss something?


Thomas
-- 
View this message in context: http://www.nabble.com/Problem-with-JavaScript-when-using-Wicket-AJAX-Components-tp14432037p14432037.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: Problem with JavaScript when using Wicket AJAX Components

Posted by Matej Knopp <ma...@gmail.com>.
Sorry, it's onRendered in AbstractBehavior.

-Matej

On Dec 21, 2007 8:13 AM, thomas jaeckle <ma...@gmail.com> wrote:
>
>
> Matej Knopp-2 wrote:
> >
> > Try this (it's a bit hacky though):
> >
> > datatable.add(new AbstractBehavior() {
> >   public final void afterRender(final Component component) {
> >      AjaxRequestTaget target = AjaxRequestTarget.get();
> >      if (target !- null) {
> >          target.appendJavascript("<your javascript to initialize the
> > tooltips>");
> >      }
> >   }
> > });
> >
> > -Matej
> >
> Overriding a final method?
> I try to find another place to put the appendJavascript ..
>
> Thanks so far.
>
> --
> View this message in context: http://www.nabble.com/Problem-with-JavaScript-when-using-Wicket-AJAX-Components-tp14432037p14451288.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
>
>

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


Re: Problem with JavaScript when using Wicket AJAX Components

Posted by thomas jaeckle <ma...@gmail.com>.

Matej Knopp-2 wrote:
> 
> Try this (it's a bit hacky though):
> 
> datatable.add(new AbstractBehavior() {
>   public final void afterRender(final Component component) {
>      AjaxRequestTaget target = AjaxRequestTarget.get();
>      if (target !- null) {
>          target.appendJavascript("<your javascript to initialize the
> tooltips>");
>      }
>   }
> });
> 
> -Matej
> 
Overriding a final method?
I try to find another place to put the appendJavascript ..

Thanks so far.

-- 
View this message in context: http://www.nabble.com/Problem-with-JavaScript-when-using-Wicket-AJAX-Components-tp14432037p14451288.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: Problem with JavaScript when using Wicket AJAX Components

Posted by Matej Knopp <ma...@gmail.com>.
Try this (it's a bit hacky though):

datatable.add(new AbstractBehavior() {
  public final void afterRender(final Component component) {
     AjaxRequestTaget target = AjaxRequestTarget.get();
     if (target !- null) {
         target.appendJavascript("<your javascript to initialize the
tooltips>");
     }
  }
});

-Matej

On Dec 20, 2007 4:33 PM, thomas jaeckle <ma...@gmail.com> wrote:
>
> I think I understand now, why the tooltips don't appear.
> The JavaScript is initialized when the Page is initialized. At this time the
> DataTable inside the AjaxLazyLoadPanel is not there.
> The JavaScript iterates over all elements I have specified ('input', 'td',
> 'tr', 'textarea', 'select', 'span', 'div', 'a','abbr','acronym') and adds
> events for them. But of course none of the DataTable - it is not there yet.
>
> But how do I specify that the JavaScript is again executed after the
> AjaxLazyLoadPanel has loaded the DataTable?
>
>
> regards Thomas
> --
> View this message in context: http://www.nabble.com/Problem-with-JavaScript-when-using-Wicket-AJAX-Components-tp14432037p14438456.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
>
>

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


Re: Problem with JavaScript when using Wicket AJAX Components

Posted by thomas jaeckle <ma...@gmail.com>.
I think I understand now, why the tooltips don't appear.
The JavaScript is initialized when the Page is initialized. At this time the
DataTable inside the AjaxLazyLoadPanel is not there.
The JavaScript iterates over all elements I have specified ('input', 'td',
'tr', 'textarea', 'select', 'span', 'div', 'a','abbr','acronym') and adds
events for them. But of course none of the DataTable - it is not there yet.

But how do I specify that the JavaScript is again executed after the
AjaxLazyLoadPanel has loaded the DataTable?


regards Thomas
-- 
View this message in context: http://www.nabble.com/Problem-with-JavaScript-when-using-Wicket-AJAX-Components-tp14432037p14438456.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