itsnt it annoying that when you have forms with multiple submit
buttons in a web2py component the button that is clicked to submit the
form is not submitted
here is a fix for web2py_ajax.html

now you can have forms with 2 or more submit buttons/images in web2py
components


diff -r 25822b3791e4 applications/welcome/views/web2py_ajax.html
--- a/applications/welcome/views/web2py_ajax.html       Mon Apr 04 14:48:36
2011 -0500
+++ b/applications/welcome/views/web2py_ajax.html       Thu Apr 07 11:44:37
2011 +0200
@@ -72,9 +72,12 @@
    jQuery('#'+target+' form').each(function(i){
       var form=jQuery(this);
       if(!form.hasClass('no_trap'))
+         $("[type=submit],[type=image]", this).click(function(e){
+             $(this).attr("was_clicked_to_submit","YES");
+         });
         form.submit(function(obj){
          jQuery('.flash').hide().html('');
-         web2py_ajax_page('post',action,form.serialize(),target);
+         web2py_ajax_page('post',action,form.serialize() + "&" + $
("[was_clicked_to_submit=YES]").attr('name') + "=" + $
("[was_clicked_to_submit=YES]").val(),target);
          return false;
       });
    });

Reply via email to