Hello all, 
I am working on an app using web2py and the jquery.mobile plug-in which I 
upgraded from v1.3.1 to v1.3.2. So far everything is working fine except 
for the image upload feature. I managed to solve the problem and enable the 
upload, but I had to hack the jquery.mobile-1.3.2.js source to make it 
work. I am making this post in order to share my experience. 

Here is the situation: when the view to do the upload includes the normal 
layout file everything works as expected. However, when using the 
plugin_jqmobile/layout.html, the upload fails with the jquery.mobile 
message "Error Loading Page" - in short the web2py callback fails. The 
record does not get inserted, neither does the response.flash error message 
appear. A couple of long sessions with javascript debugger and reading 
//api.jquery.com/submit eventually led me to suspect event.preventDefault() 
was causing the error. Indeed it was true, when I commented out that line 
of code, the upload was successful. Below is the modified code snippet from 
jquery.mobile-1.3.2.js (this problem also exists in jqm v1.3.1)

//bind to form submit events, handle with Ajax
$.mobile.document.delegate( "form", "submit", function( event ) {
var formData = getAjaxFormData( $( this ) );

if ( formData ) {
$.mobile.changePage( formData.url, formData.options );
//event.preventDefault();  //turned this off to enable web2py callbacks 
}
});

I am going to proceed with further testing. If there is a better solution, 
please let me know. Thank you.

In my controller I have the following standard code:
    form = SQLFORM(db.documnt)
    if form.accepts(request, session):
        response.flash = 'form accepted:'+str(form.vars.id)
        make_thumbnail(db.documnt,form.vars.id,(175,175))
    elif form.errors:
        response.flash = 'form has errors...'
    return dict(form=form)    

And the associated view:
  {{#extend 'layout.html'}}
  {{extend 'plugin_jqmobile/layout.html'}}

<body>
{{=form}}
</body>



-- 
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