How to define default Button?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

How to define default Button?

Sabine Manaa
Hi,

I have a page with entryfields, comboboxes etc and some buttons.
One button is the "Save" button.

I want that, if the user presses "return" somewhere at the page, the save Button is "pressed"/submitted.

How can I set the default button which is submitted when pressing the enter button?

Sabine
Reply | Threaded
Open this post in threaded view
|

Re: How to define default Button?

jtuchel
Sabine,

in HTML, teh first submit Button is the one that gets activated when you
press enter. No Exceptions to that rule (other than a so called fix to
still render it first but reposition it using css...).

In Seaside, however, you can define a defaultCallback for a form. Maybe
that is something to look into. There is a nice (but maybe dated) post
by kentreis:
http://kentreis.wordpress.com/2007/09/08/one-field-forms-and-ie-quirks/

HTH

Joachim

Am 22.07.13 16:32, schrieb Sabine Knöfel:

> Hi,
>
> I have a page with entryfields, comboboxes etc and some buttons.
> One button is the "Save" button.
>
> I want that, if the user presses "return" somewhere at the page, the save
> Button is "pressed"/submitted.
>
> How can I set the default button which is submitted when pressing the enter
> button?
>
> Sabine
>
>
>
> --
> View this message in context: http://forum.world.st/How-to-define-default-Button-tp4700070.html
> Sent from the Seaside General mailing list archive at Nabble.com.
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: How to define default Button?

Johan Brichau-2
In reply to this post by Sabine Manaa
Hi Sabine,

Is it an option to define the 'save' button as the submit button and the rest as simple buttons?
This is done by setting the type of the button.

See here: http://stackoverflow.com/questions/290215/difference-between-input-type-button-and-input-type-submit

Johan

On 22 Jul 2013, at 16:32, Sabine Knöfel <[hidden email]> wrote:

> Hi,
>
> I have a page with entryfields, comboboxes etc and some buttons.
> One button is the "Save" button.
>
> I want that, if the user presses "return" somewhere at the page, the save
> Button is "pressed"/submitted.
>
> How can I set the default button which is submitted when pressing the enter
> button?
>
> Sabine
>
>
>
> --
> View this message in context: http://forum.world.st/How-to-define-default-Button-tp4700070.html
> Sent from the Seaside General mailing list archive at Nabble.com.
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: How to define default Button?

Sabine Manaa
Hi Joachim and Johan,

I dont want to submit the page and I have n forms and buttons in various orders...

after googling for a while I found

html document addLoadScript: 'jQuery(document).keypress(function(e) {
    if (e.which == "13") {
        jQuery("#saveButton").click(); return false;
    }      
});'

as a working solution.
Now I only have to define #saveButton on each of my pages and thats all.

Sabine
Reply | Threaded
Open this post in threaded view
|

Re: How to define default Button?

Sabine Manaa
and before triggering the save button, trigger change event of the element which has current focus.
otherwise last entry will be lost

html document addLoadScript: 'jQuery(document).keypress(function(e) {
    if (e.which == "13") {
        jQuery("*:focus").trigger(''change'');
       jQuery("#saveButton").click(); return false;
    }      
});'