[development] Submit via AJAX by pressing Enter

Randy Fay randy at randyfay.com
Sun Jul 18 17:45:23 UTC 2010


Wow. Who would have known it? That was in D6 as well.

I opened http://drupal.org/node/857702 to take care of this.

If you want to take that one, feel free, or if you just want to post a
paragraph about usage there I'll get it into the FAPI reference.

-Randy

On Sun, Jul 18, 2010 at 12:21 PM, Darren Oh <
darrenoh at sidepotsinternational.com> wrote:

> Good news: if you add 'keypress' => 'true' to the form element's #ajax
> array, Drupal takes care of this automatically.
>
> On Jul 16, 2010, at 3:04 PM, Pierre Rineau wrote:
>
> > Le vendredi 16 juillet 2010 à 08:21 -0400, Darren Oh a écrit :
> >> Does Drupal 7 provide a way to AJAX-submit a form when the Enter key is
> pressed in a text field? I tried using "submit" as the event in the #ajax
> array, but that didn't prevent a page reload.
> >
> > There is no easy way to capture enter key event, you will need
> > javascript code.
> >
> > You can see this module http://drupal.org/project/default_submit (I did
> > it, by I do not advice you to use it!) which implements one way to do it
> > (not the better).
> >
> > Most browsers will use the first submit or button in the current focused
> > form when the user click enters, but a lot of others will just do
> > nothing.
> >
> > JavaScript is the key!
> >
> > Pierre.
>



-- 
Randy Fay
Drupal Module and Site Development
randy at randyfay.com
+1  970.462.7450
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20100718/3cc326c4/attachment.html 


More information about the development mailing list