Re: JavaScript onClick Handler Stops Form Submit
Thanks for the replies. I did what Pedro suggested and when I do the onClick handler in Wicket, the flow is OK now. (When I did it in HTML, I still get the alert box, but the flow would stop afterwards.) -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/JavaScript-onClick-Handler-Stops-Form-Submit-tp3533771p3535803.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: JavaScript onClick Handler Stops Form Submit
when you are using wicket in form that has already onSubmit event so your javascript onclick event won't work so you have to extend your form and override the onSubmit in wicket and add your javascript in that onSubmit function. Here is a sample code i am attaching you make changes in that to obtain your function HTML http://wicket.apache.org/dtds.data/wicket-xhtml1.5-strict.dtd"; > Wicket form helloworld JAVA package org.wick; import org.apache.wicket.ajax.AjaxRequestTarget; import org.apache.wicket.ajax.markup.html.form.AjaxButton; import org.apache.wicket.markup.html.WebPage; import org.apache.wicket.markup.html.form.Form; public class HomePage extends WebPage { public HomePage() { Form f=new Form("form"); add(f); f.add(new AjaxButton("hw",f){ /** * */ private static final long serialVersionUID = 1L; protected void onSubmit(AjaxRequestTarget target1, Form form) { target1.appendJavascript("alert(helloworld)"); } }); } } If you get anything new better than this then just post it i also posted your question and got good replies but now also i am searching for better alternatives -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/JavaScript-onClick-Handler-Stops-Form-Submit-tp3533771p3534772.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: JavaScript onClick Handler Stops Form Submit
Hi, if you are using an AJAX submit button then you can't simple change the onclick tag attribute that is already changed by the component. Prepend your alert script in the attribute rather than modify it. e.g. submitComponent.add( new Behavior(){ onComponentTat(tag){ tag.put("onclick", "alert('some alert')"+ tag.getAttribute("onclick")); } } On Wed, May 18, 2011 at 5:04 PM, eugenebalt wrote: > Hi, > > My SubmitButton has an onClick JavaScript handler. Let's say the handler is > something simple, like > > onclick="alert('Test')" > > There are no JS errors when I run. But the problem is, the form submit flow > stops. The flow doesn't go into Form.onSubmit() as it should. > > I tried returning true and false in the handler, but it doesn't help, the > flow stops. Any ideas? > > -- > View this message in context: > http://apache-wicket.1842946.n4.nabble.com/JavaScript-onClick-Handler-Stops-Form-Submit-tp3533771p3533771.html > Sent from the Users forum mailing list archive at Nabble.com. > > - > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > > -- Pedro Henrique Oliveira dos Santos - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: JavaScript onClick Handler Stops Form Submit
Please send more code. Would be great if you could put that on a quickstart project. *Bruno Borges* www.brunoborges.com.br +55 21 76727099 On Wed, May 18, 2011 at 5:04 PM, eugenebalt wrote: > Hi, > > My SubmitButton has an onClick JavaScript handler. Let's say the handler is > something simple, like > > onclick="alert('Test')" > > There are no JS errors when I run. But the problem is, the form submit flow > stops. The flow doesn't go into Form.onSubmit() as it should. > > I tried returning true and false in the handler, but it doesn't help, the > flow stops. Any ideas? > > -- > View this message in context: > http://apache-wicket.1842946.n4.nabble.com/JavaScript-onClick-Handler-Stops-Form-Submit-tp3533771p3533771.html > Sent from the Users forum mailing list archive at Nabble.com. > > - > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > >
JavaScript onClick Handler Stops Form Submit
Hi, My SubmitButton has an onClick JavaScript handler. Let's say the handler is something simple, like onclick="alert('Test')" There are no JS errors when I run. But the problem is, the form submit flow stops. The flow doesn't go into Form.onSubmit() as it should. I tried returning true and false in the handler, but it doesn't help, the flow stops. Any ideas? -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/JavaScript-onClick-Handler-Stops-Form-Submit-tp3533771p3533771.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org