views:

58

answers:

1

Hello,

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">
            Filter
        </button>
        <script type="dojo/connect" event="onSubmit" args="evt">
            filterGrid();
            dojo.stopEvent(evt);
        </script>
    </form>
</div>

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.

+2  A: 

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.

Caleb
Caleb, you are right. It appears that the DataGrid (which is just underneath) is blocking my keystrokes. It works only if I click the text field, then click somewhere else on the page, then click the text field again, and press Enter :)
Dario
Dario thanks for posting back the solved problem. It might be worth submitting this as a bug to the dojo project because it definitely should not interact that way.
Caleb