[jQuery] Setting Default Submit Button For Forms
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.