In server side when rendering the view you use python vars with
{{=my_python_var}}
If you are asking how to use a python var in client side with javascript
you can use ASSIGNJS(js_var=python_var)
Take a look at the files I uploaded before.
def mycontroller():
.....
return ASSIGNJS(js_var=python_list)
if you use ':eval' you will have a new js_var var to use with javascript.
if you use a view to fill a div you can do the same thing, but then you
will return dict(whatever=whatever) and in the view you can use
{{=ASSIGN(js_var=whatever)}} inside a script tag.
El jueves, 1 de junio de 2017, 15:44:06 (UTC+2), [email protected]
escribió:
>
> I totally agree with that but then how do you use that list in the view
> as a python variable ???
>
> Le jeudi 1 juin 2017 09:09:15 UTC+2, Junior Phanter a écrit :
>>
>> <script>
>> var list_sunda = "";
>> ajax("your_echo_url", [], ':eval');
>> </script>
>>
>> def echo_url():
>> list_sunda=[1,2,3,4,5]
>> return "list_sunda=%s;" %list_sunda
>>
>> 2017-06-01 3:49 GMT-03:00 <[email protected]>:
>>
>>> Hey paco,
>>>
>>> the problem is that i am using script, so the the action in the
>>> controller is a callback, it means that it dont have his html page.
>>>
>>> --
>>> 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.
>>>
>>
>>
--
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.