[web2py] data from controller to javascript

2017-01-24 Thread Diego Tostes
Hi, I need to send a list from controller to a javascript variable in the view. When i send the data the list to the view using: var lista = {{=dic["signals_list"]}}; and when i try to open the page i get: var lista = ['Fever', 'fever', 'dor no corpo', 'enxaqueca']; How can i fix this? R

Re: [web2py] data from controller to javascript

2017-01-24 Thread António Ramos
try var lista = {{=*XML(*dic["signals_list"]*)*}}; http://www.web2pyref.com/reference/xml-html-helper 2017-01-24 11:37 GMT+00:00 Diego Tostes : > Hi, > > > I need to send a list from controller to a javascript variable in the view. > > > When i send the data the list to the view using: > > > va

Re: [web2py] data from controller to javascript

2017-01-24 Thread Diego Tostes
Thanks Ramos! 2017-01-24 10:42 GMT-02:00 António Ramos : > try > var lista = {{=*XML(*dic["signals_list"]*)*}}; > > > http://www.web2pyref.com/reference/xml-html-helper > > 2017-01-24 11:37 GMT+00:00 Diego Tostes : > >> Hi, >> >> >> I need to send a list from controller to a javascript variable i

Re: [web2py] data from controller to javascript

2017-01-24 Thread Anthony
On Tuesday, January 24, 2017 at 7:43:24 AM UTC-5, Ramos wrote: > > try > var lista = {{=*XML(*dic["signals_list"]*)*}}; > To be safe, you might instead want to convert the Python object to JSON: var lista = {{=json.dumps(dic['signals_list'])}}; The latter approach will always generate a valid J

Re: [web2py] data from controller to javascript

2017-01-25 Thread Gaurav Vichare
Or you can use ASSIGNJS helper {{=ASSIGNJS(js_array = python_list)}} http://gauravvichare.com/how-to-assign-python-variable-to-javascript-variable-in-web2py/ On Tuesday, January 24, 2017 at 9:22:08 PM UTC+5:30, Anthony wrote: > > On Tuesday, January 24, 2017 at 7:43:24 AM UTC-5, Ramos wrote: >>

Re: [web2py] data from controller to javascript

2017-01-25 Thread Anthony
On Wednesday, January 25, 2017 at 6:22:22 AM UTC-5, Gaurav Vichare wrote: > > Or you can use ASSIGNJS helper > > {{=ASSIGNJS(js_array = python_list)}} > Yes, good suggestion. As an additional benefit, it uses gluon.serializers.json, which can handle conversion of datetimes, decimals, and various