view raw
Dario Dario - 6 months ago 48
Javascript Question

Dojo - submitting form by pressing Enter

I have the following code:

<div dojoType="dijit.layout.ContentPane" id="filterForm" style="padding: 3px">
<form dojoType="dijit.form.Form">
<input dojoType="dijit.form.TextBox" style="width: 120px" />
<button dojoType="dijit.form.Button" type="submit">
<script type="dojo/connect" event="onSubmit" args="evt">

It works as expected if I click the Filter button, however I would like the same behavior when user presses Enter, while textbox is focused. This doesn't happen, though. In fact, nothing happens when I press Enter. How can I have the onSubmit handler execute upon pressing Enter? Thanks.


Dario this should work. Something else in your environment is screwing it up. You might have another bit of script that is intercepting keystrokes. This could be in your scripts on the web page or even in your browser environment such as a grease monkey script or other extention.

You should setup a minimal test case where the web page includes only some bare minimal html including that form and load dojo from the aol or google CDN's and try the enter. If it doesn't work give us a full copy of (or the URL to) your test and we'll try to see what's going wrong, but I suspect that will work. Then you need to work backwards between the minimal test case and your full site environment until you find the conflicting bit of script.