Just looking through some of our forms and this isn;t going to work where we have 2 ajaxbuttons in the same form. I suppose we'll need to separate the forms or something now.
On Thu, Feb 26, 2009 at 9:06 AM, Wayne Pope <[email protected]> wrote: > Hi Jeremy, > > thanks very much for helping. > > I went with the first suggestion which seems to work fine. > The code is essentially now: > > = new Form() { > > add(new AjaxButton() { > void onSubmit() { > if(!form.isSubmitted()) { > onSubmit(); > } > } > > void onSubmit() { > > IRequestTarget iTarget = RequestCycle.get().getRequestTarget(); > AjaxRequestTarget target= null; > if (iTarget instanceof AjaxRequestTarget) { > target = (AjaxRequestTarget) iTarget; > } > > //logic.. > > } > } > > > Looks like I'm going to have to go through all our forms and apply > this pattern where we have ajaxbuttons or ajaxlinks. > thanks > > > On Wed, Feb 25, 2009 at 7:47 PM, Jeremy Thomerson > <[email protected]> wrote: >> Actually, thinking a little more - rather than disabling the return key, >> could you do something like this in JS (pseudo code): >> >> <form onsubmit="ajaxSubmitButton.submit(); return false;"> >> blah blah blah >> </form> >> >> Then when the return key was pressed, the form would submit, and if they >> have JS, it will use the ajaxsubmitbutton and stop the normal form >> submission? And if they don't have JS, it will just work as a normal form. >> >> -- >> Jeremy Thomerson >> http://www.wickettraining.com >> >> On Wed, Feb 25, 2009 at 12:45 PM, Jeremy Thomerson < >> [email protected]> wrote: >> >>> This probably isn't the best way, but you could possibly move all of your >>> onSubmit code to the form's on submit, including the request target stuff. >>> >>> Just do RequestCycle.get().getRequestTarget() (or there maybe >>> AjaxRequestTarget.get() - I can't remember). >>> >>> That's not a true "fix" but at least it gets rid of the duplicate code >>> issue. Someone else may have a suggestion on how to do a real fix. >>> >>> -- >>> Jeremy Thomerson >>> http://www.wickettraining.com >>> >>> >>> >>> On Wed, Feb 25, 2009 at 11:57 AM, Wayne Pope < >>> [email protected]> wrote: >>> >>>> Hi, >>>> >>>> I have a form that has a single text field and an ajax button. >>>> In FF when I click on the button or hit return key the onSumit of the >>>> ajaxButton is called. >>>> In IE when I click on the button the onSubmit of the ajaxButton is called. >>>> However >>>> In IE (as you may know) if I hit the return key it submits the form >>>> and the form's onSubmit method is be called instead of the ajaxButton >>>> so the page just refreshes. >>>> If I add the onSubmit to the form, in FF if I click on the button , >>>> first the onSubmit of the form is called, then the ajaxButton >>>> onSubmit, and we end up with double the submits >>>> >>>> Aside from disabling the return key via javascript - not really an >>>> option as its just bad usability for us - any suggestions on how to >>>> handle this in a more elegant way? >>>> >>>> For the moment I've used form.isSubmitted() in the ajaxButton >>>> onSubmit, but it means I have to duplicate some of the code between >>>> the 2 onSubmits to control ajaxrequestTarget . >>>> thanks >>>> Wayne >>>> >>>> >>>> >>>> >>>> >>>> >>>> www.glasscubes.com >>>> >>>> --------------------------------------------------------------------- >>>> 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]
