This is the last form event so it's good for double click prevention. There are other form events that happen sooner.
On Tuesday, December 2, 2014, Charlouze <m...@charlouze.com> wrote: > @Barry: This is a good idea to use the prepareForSubmit event but it occurs > after validation so you have to have a fast validation (which is the case > for most of apps, mine included). > > 2014-12-02 12:29 GMT+01:00 Barry Books <trs...@gmail.com <javascript:;>>: > > > Here is the one I wrote for 5.4. It uses the perpareForSubmit form event > > > > > > define(["jquery","t5/core/events"], *function*($,events) { > > > > > > > > *return* *function*(parameters) { > > > > $('#'+parameters.id + ' :submit').removeAttr('disabled'); > > > > > > > > $('#'+parameters.id).bind(events.form.prepareForSubmit, > > *function*() { > > > > $('#'+parameters.id + ' :submit').attr('disabled', > > 'disabled'); > > > > $('#'+parameters.id + ' :submit').val("Please Wait") > > > > }); > > > > }; > > > > }); > > > > > > > > *public* *class* Sub1 { > > > > @Inject > > > > *private* JavaScriptSupport javaScriptSupport; > > > > > > > > @Inject > > > > *private* FormSupport formSupport; > > > > > > > > *void* afterRender(MarkupWriter writer) { > > > > JSONObject params = *new* JSONObject(); > > > > params.put("id",formSupport.getClientId()); > > > > javaScriptSupport.require("sub1").with(params); > > > > } > > > > > > > > } > > > > On Tue, Dec 2, 2014 at 5:04 AM, Thiago H de Paula Figueiredo < > > thiag...@gmail.com <javascript:;>> wrote: > > > > > On Tue, 02 Dec 2014 01:25:18 -0200, Charlouze <m...@charlouze.com > <javascript:;>> wrote: > > > > > > @Thiago: I'd like to inform my user that the form is currently being > > sent > > >> (using an ajax request). That's why I need something similar to the > > >> clickOnce example. > > >> > > > > > > You can do that by adapting the example I provided. > > > > > > You've been actually asking for two different things: preventing double > > > submission and some way of knowing a validation error occurred. The > > first > > > one can be done by adapting the example I provide. The second one can > be > > > implemented now by checking whether the validation error message HTML > > > elements are visible. > > > > > > Do you think that adding a validation error event isn't a good idea > > >> anyway ? (It would probably serves other purpose for other > > >> people) > > >> > > > > > > Yep! JIRA please? :) > > > > > > > > > -- > > > Thiago H. de Paula Figueiredo > > > Tapestry, Java and Hibernate consultant and developer > > > http://machina.com.br > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > <javascript:;> > > > For additional commands, e-mail: users-h...@tapestry.apache.org > <javascript:;> > > > > > > > > >