[web2py] Re: ajax callback update css value

2015-05-23 Thread Dmitry Ermolaev
If you return JQuery script - not need to use any view template DIV( ... _onclick = "ajax(%s, [name1, name2, ...], ':eval');" % URL(controller, 'calback_0') def callback_0(): return '$(...)' -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py

[web2py] Re: ajax callback update css value

2015-05-21 Thread 黄祥
for anthony's post, i think you can see it in the web2py google groups. he explain detail about this. for your another question, this is my full code of the cutted code above that work. *modules/transaction.py* def callback_0(session_order): id = int(current.request.vars.id) if current.request.va

[web2py] Re: ajax callback update css value

2015-05-21 Thread Dave S
On Thursday, May 21, 2015 at 4:06:07 PM UTC-7, 黄祥 wrote: > > I don't understand why you have the same calculation in your controller >> and your view, >> > > not sure what do you mean about calculation, i think is about variable > definition (status and value) i define it on controllers and vi

[web2py] Re: ajax callback update css value

2015-05-21 Thread 黄祥
> > I don't understand why you have the same calculation in your controller > and your view, > not sure what do you mean about calculation, i think is about variable definition (status and value) i define it on controllers and views e.g. 1. if i'm not define the variable status and value in vi

[web2py] Re: ajax callback update css value

2015-05-21 Thread Dave S
On Wednesday, May 20, 2015 at 10:41:16 PM UTC-7, 黄祥 wrote: > > hi, > > is it possible to have ajax callback return that update css value? > e.g. > *controller* > def callback_2(session_order): > """ cutted """ > if int(total_debit) == int(total_credit): > status = 'Balance' > value = 'text-succes

[web2py] Re: ajax callback update css value

2015-05-21 Thread 黄祥
that's do the trick, thank you so much anthony for your help. e.g. *controllers* return "jQuery('#status').html('%s'); jQuery('#status').removeClass().addClass('%s');" % (status, value) *views* {{if total_debit == total_credit:}} {{status = "Balance" }} {{value = "text-success" }} {{=SPAN(status,

[web2py] Re: ajax callback update css value

2015-05-21 Thread Anthony
I think there are two problems. First, the class of an element is not a CSS property, so you probably have to use removeClass and addClass. Second, you have attempted to pass the Python "value" variable directly into the Javascript code rather than use string formatting as you (properly) did wi