This first part works fine on its own.  It's when I try to make this part 
of an AJAX component inside another page that it fails.

Model:
db.define_table('temp_pics',
Field('image', 'upload', required=True, notnull=True, requires=IS_IMAGE()))

Controller:
# This will reload itself and allow changing the photo after submission.
def upload_temp():
record = db.temp_pics(request.args(0))
pic_upload = SQLFORM(db.temp_pics, record, upload=URL('download'))
if pic_upload.process(formname='pic_upload').accepted:
id = pic_upload.vars.id
redirect(URL('upload_temp', args=id),client_side=True)
return dict(pic_upload=pic_upload)

View:
{{=pic_upload}}

Now I want to put this in a different view using:
{{=LOAD('default', 'upload_temp','upload_temp.load',ajax=True)}}

If I set ajax=False, it will work, but reload the whole page, which fully 
defeats the purpose.

Somewhere you need to have this script referenced (and you'll have to 
download that script online first):
src="{{=URL('static', 'js/jquery.form.js')}}"

And in the default/upload_temp.html (and identical upload_temp.LOAD), you 
need to have this:

{{=pic_upload}}
<script>
//<!--
$('document').ready(function() {
$('pic_upload').ajaxForm({dataType: 'script', // <-- like the ':eval' 
target in ajax() function
url: "{{=URL(args=pic_upload.vars.id)}}" // <-- put form controller action 
here
});
});
</script>


Is there a way to make this work?  The book just says AJAX doesn't do 
forms, but doesn't go on to explain how I should handle this sort of thing. 
 Any help is much appreciated!

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