Looks like the JS code disables any submit button inside a form if the 
button has no "name" attribute, so a workaround would be to give the button 
a name:

BUTTON(icon_text('Export', 'print'), _type='submit', _class='btn', _name=
'export')

Perhaps there should be a more elegant way to prevent the automatic 
disabling. Feel free to submit a Google Code issue about this.

Anthony

On Monday, November 3, 2014 7:17:39 AM UTC-5, [email protected] 
wrote:
>
> I have a form which allows a user to download a CSV, given a batch number, 
> without having to leave the page.  However, I'd like to allow form 
> re-submission, since the user might want to run the CSV export several 
> times.  Web2py.js disables buttons on form submission, but is there a 
> simple way to suppress this behaviour for a single form?  (I've found I can 
> replace the form's .submit() in Javascript, but that seems like 
> overengineering, and I'd end up putting boilerplate in any number of views)
>
> def search():
>      export_form = FORM(LABEL('Export batch #'),
>                     DIV(
>                         INPUT(_type='text', _name='number', 
> _class="span2", _id="appendedInputButton"),                                 
>        
>                         BUTTON(icon_text('Export', 'print'), 
> _type='submit', _class='btn'), _class='input-append',                     
>    
>                         ),
>                     _action=URL(export, extension='csv')
>                     )
>                             
>     return dict(export_form=export_form)
>     
> def export():
>     query = idb.tutor_fee.batch == request.vars.number
>     tutors = idb(query).select(idb.tutor_fee.ALL)    
>     return dict(tutors=tutors)
>
> search.html
> {{extend 'layout.html'}}
> ...
> {{=export_form}}
>
> export.csv:
> {{    
> import cStringIO
> stream = cStringIO.StringIO()
>
> tutors.export_to_csv_file(stream)
>
> response.headers['Content-Type']='text/csv'
> response.write(stream.getvalue(), escape=False)
> }}
>
>
>

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to