>Have you ever seen this done with an entire form, instead of just a
>single input element?
>
>I would like to be able to do something like:
>
>$
>('#my_form').defaultButton('#btn_submit').cancelButton('#btn_cancel');
>
>I found a plugin on the JQuery list that did this for an input
>element, but not the whole form.
>
>The only other option I could think of would be to create a plug-in
>that did a DOM traversal through the form, looking for INPUT elements,
>and then adding some kind of key binding on each element it found. I
>would hope there would be a better way though.
>
>The whole point if this is that when hitting the enter key, while in
>an input (text) element, the browser normally submits the form with
>the POST data representing that the user clicked the first input
>(button) element. I want to be able to set which button is sent.
It sounds like maybe you've created a form that has multiple submit buttons
that also have a name attribute:
<input type="submit" name="action" value="Submit" />
<input type="submit" name="action" value="Cancel" />
If that's correct, then if the user submits the form using the [ENTER] key,
the POST data shouldn't contain a variable called "action", so just perform
the desire if the user didn't click the button.
Adding event handling for this is overkill.
-Dan