Yes, in the controller, and just us the URL function as usual.

Anthony

On Wednesday, January 13, 2016 at 2:17:22 PM UTC-5, Ron Chatterjee wrote:
>
> Yes. That's what I thought too. But what's the correct syntax for 
> response.js Anthony?
>
> Is it:
>
> response.js = 'window.location = "%s";' % URL
> ('default',show_project_summary')
>
> ?
> And I believe I need to invoke that in my controller. Right?
>
>
>
> On Wednesday, January 13, 2016 at 2:06:34 PM UTC-5, Anthony wrote:
>>
>> Where is:
>>
>> {{redirect(URL('show_project_summary', args = Selected_project.id), 
>> client_side = True)}}
>>
>> If that's in a view file for upload_callback, it will never get executed, 
>> because upload_callback doesn't return a dictionary.
>>
>> You can call redirect(..., client_side=True) within the upload_callback 
>> function, though that will skip the returning of the {"success": "true"} 
>> JSON response (though perhaps you don't need that, as returning a 200 
>> response may be sufficient to imply success). Alternatively, you can set 
>> response.js:
>>
>>     response.js = 'window.location = "%s";' % URL(...)
>>
>> That's really all the client side redirect does.
>>
>> Anthony
>>
>> On Wednesday, January 13, 2016 at 1:51:51 PM UTC-5, Ron Chatterjee wrote:
>>>
>>> Basically after the file upload, I would like to refresh/reload 
>>> "show_project_summary.html" to show the list of the file that just been 
>>> downloaded. 
>>>
>>>
>>>
>>> On Wednesday, January 13, 2016 at 1:49:42 PM UTC-5, Ron Chatterjee wrote:
>>>>
>>>> *I have this in my view (show_project_summary.html).*
>>>>
>>>>
>>>>     
>>>> {{ if (submission.created_by == auth.user_id):}}
>>>> <div id="file-uploader"></div>
>>>> {{pass}}
>>>>     
>>>>
>>>>
>>>>
>>>>
>>>> *Script in the same view at the bottom:*
>>>>
>>>> <script>
>>>> jQuery(document).ready(function() {
>>>>   var uploader = new qq.FileUploader({
>>>>         // pass the dom node (ex. jQuery(selector)[0] for jQuery users)
>>>>         element: document.getElementById('file-uploader'),
>>>>         // path to server-side upload script
>>>>         action: 
>>>> '{{=URL("upload_callback_submission")}}/{{=request.args(0)}}',
>>>>         sizeLimit: 150000000,
>>>>         minSizeLimit: 0,
>>>>         allowedExtensions: ['xls','jpg', 'jpeg', 'pdf', 
>>>> 'txt','doc','docx','ppt', 'pptx', 'htm','html','xml','xmls', 
>>>> 'txt','ppt','png', 'gif'],
>>>>         // set to true to output server response to console
>>>>         debug: true,
>>>>
>>>>         // events
>>>>         // you can return false to abort submit
>>>>         onSubmit: function(id, fileName){},
>>>>         onProgress: function(id, fileName, loaded, total){},
>>>>         onComplete: function(id, fileName, responseJSON){},
>>>>         onCancel: function(id, fileName){},
>>>>
>>>>         messages: {
>>>>             // error messages, see qq.FileUploaderBasic for content
>>>>             typeError: "{file} {{=T('has invalid extension.')}} 
>>>> {{=T('Only')}} {extensions} {{=T('are allowed.')}}",
>>>>             sizeError: "{file} {{=T('is too large, maximum file size 
>>>> is')}} {sizeLimit}.",
>>>>             minSizeError: "{file} {{=T('is too small, minimum file size 
>>>> is')}} {minSizeLimit}.",
>>>>             emptyError: "{file} {{=T('is empty, please select files 
>>>> again without it.')}}",
>>>>             onLeave: "{{=T('The files are being uploaded, if you leave 
>>>> now the upload will be cancelled.')}}"
>>>>         },
>>>>         showMessage: function(message){ alert(message); }
>>>>     });
>>>>     });
>>>> </script>
>>>>
>>>>
>>>>
>>>> *In my default controller:*
>>>>
>>>> def upload_callback():
>>>>     Selected_project = []
>>>>     #Rendering rule for Post
>>>>     Selected_project = db.Project(request.args(0, cast=int))
>>>>     db.Project_Files.Project_id.default = Selected_project.id;
>>>>     project = db.Project[request.args(0)]
>>>>     if Selected_project is None:
>>>>         raise HTTP(404)
>>>>     if 'qqfile' in request.vars:
>>>>         filename = request.vars.qqfile
>>>>         newfilename = db.Project_Files.filename.store(request.body, 
>>>> filename)
>>>>         db.Project_Files.insert(Project_id=Selected_project.id, 
>>>> filename=newfilename)
>>>>     return response.json({'success': 'true'})
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> On Wednesday, January 13, 2016 at 1:43:10 PM UTC-5, Anthony wrote:
>>>>>
>>>>> Please show some code.
>>>>>
>>>>> On Wednesday, January 13, 2016 at 1:37:16 PM UTC-5, Ron Chatterjee 
>>>>> wrote:
>>>>>>
>>>>>> How do I update a current page in its view after a file submission if 
>>>>>> the redirect doesn't work?
>>>>>>
>>>>>> {{redirect(URL('show_project_summary', args = Selected_project.id), 
>>>>>> client_side = True)}}
>>>>>>
>>>>>> Any response.js that will update or reload/refresh the current page?
>>>>>>
>>>>>>

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