Uploads don't work in ajax loaded forms without some trickery. Here's a 
possible solution

You need jquery.form.js <http://malsup.com/jquery/form/> then you need to 
put something like this javascript right after web2py.js is loaded, this 
will change the default way web2py traps forms so it deals with form with 
upload fields using jquery.form.js.

        $.web2py.trap_form = function (action, target) {
          /* traps any LOADed form */
          $('#' + target + ' form').each(function (i) {
            var form = $(this);
            if (form.hasClass('no_trap')) {
              return;
            }


            form.attr('data-w2p_target', target);
            var url = form.attr('action');


            if ((url === "") || (url === "#")) {
              /* form has no action. Use component url. */
              url = action;
            }


            if(form.find('.input-file').length>0) {
                form.ajaxForm({
                    url: action,
                    success: function(data, statusText, xhr) {
                        jQuery('#'+target).html(xhr.responseText);
                        $.web2py.trap_form(action,target);
                        $.web2py.ajax_init();
                    }
                });
            }
            else {
                form.submit(function (e) {
                  $.web2py.disableElement(form.find($.web2py.
formInputClickSelector));
                  $.web2py.hide_flash();
                  $.web2py.ajax_page('post', url, form.serialize(), target, 
form);
                  e.preventDefault();
                });
            }
          });
        };

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to