on button click show progress bar

179 views
Skip to first unread message

Yebach

unread,
Mar 3, 2016, 9:18:00 AM3/3/16
to web2py-users
Hello

I have call to controller function on button click that serves back a download file. 

Since this can take a while (up to 10 seconds), i would like to create some sort of progress bar or smth for user so he/she knows smth is going on in the background and does not click 10 times.

Any solutions/suggestions?

thank you


Dave S

unread,
Mar 3, 2016, 7:49:30 PM3/3/16
to web2py-users
If you're using the LOAD helper, the content arg specifies a message to display.

{{loadmsg = CAT("loading ...", BR(), SPAN(_class="fa fa-spinner fa-spin"))}}
{{=LOAD(c='makestuff', f='stuff2.load', target='my_stuff', content=loadmsg, ajax=True)}}


fa-spinner is an object that the browser animates via CSS, but you can put text, or other stuff there (I have also used a font that provides animation)).  Someone in the group pointed me at the resource, which is a website that generates a CSS clip based on your choice of colors, etc.  Someone in the group pointed me at it, so the URL should be in the group archives.

If you're using ajax directly, I think you'd want your onclick function to display your "loading" message  before calling ajax().

If you are providing a button or link that is just directing the user to another page, you may want an onclick handler to display a flash message or unhide a "please wait" message.

This is a javascript issue, mostly (AIUI).

/dps


 

Yebach

unread,
Mar 11, 2016, 7:31:02 AM3/11/16
to web2py-users
am not using LOAD helper. Maybe i should. 

this is my html

<div class="btn-group" style="margin-bottom: 20px; margin-top: 10px;">

{{=A(T('Report'), _class='btn btn-primary', _href=URL('script','excelExport', args = request.args[0]))}}
</div>

And my controller code which at the end

data = open(tmpfilename,"rb").read()
os.unlink(tmpfilename)
response.headers['Content-Disposition']='attachment;filename=%s.xlsx' % (fleName)
response.headers['Content-Title']=fleName
return data

Do you suggest another approach. I want to serve excel file

Thank you
Reply all
Reply to author
Forward
0 new messages