On Sunday, September 11, 2011 10:57:27 PM UTC-4, Noel Villamor wrote:
>
> I have a button which does the following callback: 
>
> ajax('{{=URL('callback')}}',['btn1'],':eval');" 
>
> Then I have the following callback function in my controller: 
>
> def callback(): 
>     db(db.tbl.id==100).update(data='sampledata') 
>     jquery = ??? 
>     return jquery 
>
> I can use jquery = "alert('Lame table update message');" but it 
> doesn't appear as good as the response.flash message.


> 1) How do I emulate response.flash? 
>

jQuery('.flash').html('your flash message').slideDown()

That's how the web2py_ajax_page() function in /static/js/web2py_ajax.js does 
it when an Ajax component returns a flash message.
  

> 2) How to determine if the db update is successful or not so I can 
> flash the appropriate message.
>

.update() should return the number of rows updated, so maybe just:

if db(db.tbl.id==100).update(data='sampledata'):
    flash='success'
else:
    flash='failure'

Anthony

Reply via email to