I knew about this but this requires adding files to the scaffolding
apps that 99% of users would not use.

What do other people think?

Massimo

On Sep 30, 2:34 am, selecta <[email protected]> wrote:
> *bump*
>
> this actually solves the problem of file uploads in LOAD loaded forms
>
> I send the patch for the examples web2py_ajax.html because I do not
> know which is the main web2py_ajax.html
> please include this fix in web2py
>
> On Sep 28, 10:53 pm, selecta <[email protected]> wrote:
>
> > After spending time and time again with this problem I found a
> > solution for uploading files in forms loaded with web2py LOAD/
> > web2py_component
>
> > download jquery.form.jshttp://jquery.malsup.com/form/tostatic/js
> > put a loading.gif image into static/img (just for style)
>
> > apply the patch to the examples/views/web2py_ajax.html
> > and copy the new web2py_ajax.html to your app
>
> > diff --git a/applications/examples/views/web2py_ajax.html b/
> > applications/examples/views/web2py_ajax.html
> > --- a/applications/examples/views/web2py_ajax.html
> > +++ b/applications/examples/views/web2py_ajax.html
> > @@ -2,6 +2,7 @@
> >  response.files.insert(0,URL(r=request,c='static',f='jquery.js'))
> >  response.files.insert(1,URL(r=request,c='static',f='calendar.css'))
> >  response.files.insert(2,URL(r=request,c='static',f='calendar.js'))
> > +response.files.insert(3,URL(r=request,c='static/
> > js',f='jquery.form.js'))
> >  for _item in response.meta or []:}}
> >       <meta name="{{=_item}}" content="{{=response.meta[_item]}}" />{{
> >  pass
> > @@ -65,12 +66,22 @@
> >  function web2py_trap_form(action,target) {
> >     jQuery('#'+target+' form').each(function(i){
> >        var form=jQuery(this);
> > -      if(!form.hasClass('no_trap'))
> > -        form.submit(function(obj){
> > -         jQuery('.flash').hide().html('');
> > -         web2py_ajax_page('post',action,form.serialize(),target);
> > -         return false;
> > -      });
> > +      if(!form.hasClass('no_trap')){
> > +         form.ajaxForm({
> > +               url: action,
> > +            beforeSubmit: function(a,f,o) {
> > +                  $
> > ('#'+target).html('{{=IMG(_src=URL(request.application,'static/
> > img','loading.gif') ,_alt='loading')}} Submitting...');
> > +               },
> > +               success: function(data) {
> > +                  $('#'+target).html(data);
> > +               web2py_trap_form(action,target);
> > +               web2py_ajax_init();
> > +               if(command) eval(command);
> > +               if(flash) jQuery('.flash').html(flash).slideDown();
> > +               return false;
> > +               }
> > +         });
> > +      }
> >     });
> >  }
>
> > i have not tested it enough to really say that it should be included
> > in the web2py code but after some more testing it should be included
>
> > also I wanted to ask: massimo can you "clean up" the static folder and
> > create some subfolders
>
> > /static/js/
> > /static/css/
> > /static/img/
>
>

Reply via email to