I'm pretty sure I already tried that. But I'll have a go at it again.
Thanks Massimo!
On Saturday, May 24, 2014 9:58:45 PM UTC+8, Massimo Di Pierro wrote:
>
> def mymodule():
> from gluon.serializers import json
> T = current.T
> x = [T('fee'),T('fie'),T('foe'),T('fum')] # I want to use the
> translated values in the script below
> return CAT(
> DIV(... some stuff ...),
> SCRIPT("""$(function() {
> x = %(x)s;
> ... do something with x ...
> """ % dict(x=json(x))
> )
>
> On Saturday, 24 May 2014 03:00:12 UTC-5, weheh wrote:
>>
>> I've seen this one asked regarding how to pass python array into
>> javascript array inside of a view, but here I want to do it inside a SCRIPT
>> and it's eluding me. I have a module.py that's generating a button with
>> pulldown. I want to be able to do something like this:
>>
>> def mymodule():
>> T = current.T
>> x = [T('fee'),T('fie'),T('foe'),T('fum')] # I want to use the
>> translated values in the script below
>> return CAT(
>> DIV(... some stuff ...),
>> SCRIPT("""$(function() {
>> x = %(x)s;
>> ... do something with x ...
>> """ % dict(x=x)
>> )
>>
>> If also tried wrapping XML(json(x)) in the dict() part in the end. No
>> dice. Any thoughts how to do it gracefully?
>>
>
--
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.