Perfect. Thanks! On Fri, 5 Sep 2008 15:53:12 +0200, "Matej Knopp" <[EMAIL PROTECTED]> said: > if you use renderOnDomReadyJavascript method of IHeaderResponse it > will be invoked after ajax request. > > -Matej > > On Fri, Sep 5, 2008 at 3:41 PM, Pointbreak > <[EMAIL PROTECTED]> wrote: > > I have a couple of behaviors that add javascript to the header of a > > document, to change attributes or add event scripts to components (using > > jquery onready, but that's not the point). This all works fine. There is > > just one problem: when I use such components in an ajax > > request/response, it won't have the javascript added attributes anymore, > > because the component gets replaced by the wicket ajax call. > > > > I'm looking for a way to make the behaviors add the necessary javascript > > to add the attributes again, when an ajax response is created. E.g. a > > way to let behaviors add a script to every ajax response, or let them > > add script tags after the rendering of the component. Is there a way to > > do this in Wicket? > > > > I know I could make a custom panel/component that just has an extra > > script tag, but that's far to intrusive, and makes it really difficult > > to make different combinations of these behaviors. > > > > Example behavior class: > > > > public class DatePickerBehavior extends AbstractBehavior { > > private String createOnReadyScript(String markupId) { > > return "$(document).ready(function(){\n " + > > createPickerScript(markupId) + "\n});"; > > } > > > > private String createPickerScript(String markupId) { > > return "$('#" + markupId + "').datepicker();"; > > } > > > > public void bind(Component component) { > > super.bind(component); > > component.add(new HeaderContributor(new IHeaderContributor() { > > public void renderHead(IHeaderResponse response) { > > > > response.renderJavascript(createOnReadyScript(component.getMarkupId()), > > null); > > } > > })); > > //Is there a way to instead of contributing to the header, add > > the script to the document body after the rendering of > > // the component itself. > > //Or a way to add a script to every ajax request? > > } > > } > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] >
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]