something like: new AjaxLink("link") { protected onClick(AjaxRequestTarget target) { ...} protected IAjaxCallDecorator getAjaxCallDecorator() { return new AjaxCallDecorator() { public CharSequence decorateScript(CharSequence script) { return "alert('w00t'); " + script; } } } }
On Jan 10, 2008 2:16 PM, mbelarbi <[EMAIL PROTECTED]> wrote: > > How would i do that for what i have? > > Gerolf Seitz wrote: > > > > you need to override getAjaxCallDecorator() on the AjaxLink and return a > > new > > > > AjaxCallDecorator that either prepends, appends (or both) your custom > > javascript to the javascript created by the link. > > > > cheers, > > Gerolf > > > > On Jan 10, 2008 11:05 AM, mbelarbi <[EMAIL PROTECTED]> wrote: > > > >> > >> Hi, I want to call a javascript function ( myFunction() ) on a > >> component's > >> onclick event. > >> > >> I tried this: > >> > >> a wicket:id="myLink" onClick="myFunction();" > >> > >> but then i realized that my wicket's onClick() method is overwriting > the > >> above html one. > >> > >> ------ > >> AjaxLink agentLink = new AjaxLink("myLink") { > >> > >> public void onClick(AjaxRequestTarget target) { > >> /* Some Code */ > >> } > >> }; > >> ----- > >> > >> So then i tried this: > >> > >> ------ > >> AjaxLink agentLink = new AjaxLink("myLink") { > >> > >> public void onClick(AjaxRequestTarget target) { > >> target.appendJavascript("alert('hi from > >> wicket');"); > >> /* Some Code */ > >> } > >> }; > >> ----- > >> > >> > >> But i don't see the alert when i click the link, can someone help me > out? > >> -- > >> View this message in context: > >> > http://www.nabble.com/calling-javascript-function-on-wicket-component%27s-onclick-tp14730927p14730927.html > >> Sent from the Wicket - User mailing list archive at Nabble.com. > >> > >> > >> --------------------------------------------------------------------- > >> To unsubscribe, e-mail: [EMAIL PROTECTED] > >> For additional commands, e-mail: [EMAIL PROTECTED] > >> > >> > > > > > > -- > View this message in context: > http://www.nabble.com/calling-javascript-function-on-wicket-component%27s-onclick-tp14730927p14732418.html > Sent from the Wicket - User mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > >