Wow. Who would have known it? That was in D6 as well.<br><br>I opened <a href="http://drupal.org/node/857702">http://drupal.org/node/857702</a> to take care of this.<br><br>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.<br>
<br>-Randy<br><br><div class="gmail_quote">On Sun, Jul 18, 2010 at 12:21 PM, Darren Oh <span dir="ltr"><<a href="mailto:darrenoh@sidepotsinternational.com">darrenoh@sidepotsinternational.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Good news: if you add 'keypress' => 'true' to the form element's #ajax array, Drupal takes care of this automatically.<br>
<div><div></div><div class="h5"><br>
On Jul 16, 2010, at 3:04 PM, Pierre Rineau wrote:<br>
<br>
> Le vendredi 16 juillet 2010 à 08:21 -0400, Darren Oh a écrit :<br>
>> 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.<br>
><br>
> There is no easy way to capture enter key event, you will need<br>
> javascript code.<br>
><br>
> You can see this module <a href="http://drupal.org/project/default_submit" target="_blank">http://drupal.org/project/default_submit</a> (I did<br>
> it, by I do not advice you to use it!) which implements one way to do it<br>
> (not the better).<br>
><br>
> Most browsers will use the first submit or button in the current focused<br>
> form when the user click enters, but a lot of others will just do<br>
> nothing.<br>
><br>
> JavaScript is the key!<br>
><br>
> Pierre.<br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Randy Fay<br>Drupal Module and Site Development<br><a href="mailto:randy@randyfay.com">randy@randyfay.com</a><br>+1 970.462.7450<br><br>