I was asking for the code handling it, but I suppose I got it .... you 
check for, e.g., request.post_vars.thebuttonname == thebuttonvalue

Got also why jquery "doesn't do the smart thing".
Spotted also a little error related to the disableformelement function 
(will send a PR to fix it) in certain conditions....

What about this ?

trap_form: function (action, target) {
      /* traps any LOADed form */
      $('#' + target + ' form').each(function (i) {
        var form = $(this);
        form.attr('data-w2p_target', target);
        if(!form.hasClass('no_trap')) {
          var form_data = form.serializeArray();
          form.on('click', web2py.formInputClickSelector, function (e) {
            var input_name = $(this).attr('name');
            if (input_name != undefined) {
              form_data.push({name : input_name , value : $(this).val()})
            }
            web2py.disableElement(form.find(web2py.formInputClickSelector));
            web2py.hide_flash();
            web2py.ajax_page('post', action, $.param(form_data), target, 
form);
            e.preventDefault();
          })
        }
      });
    },

seems to work fine in FF, Chrome, IE9/10/11.
This seems to "fix" the misbehaviour between what the submit handler does 
by default and what ajax "should" do. Of course we need to bind to the 
click on the buttons rather than on the submission of the form...
I'm wondering if there is something "bad" to completely replace the submit 
event with the click event on the "submit" buttons...
If there is one (and I'd like to see it, so I'll learn yet another thing) 
the only method would be to create an hidden field and let the "usual" 
submit handler to deal with it.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to