El 27/02/13 11:11, vrs762 escribió:
Hi,

I have my controller returning an array of floats called arrVals to a kid template file.

In the template file within the javascript code block, when I do a <?python print arrVals ?>, I get the right output, which is [0.2, 0.4, 0.6, 0.8]

However, when I try assigning arrVals to a javascript variable like this:

var dataset[];
dataset = "${bars}";
alert(dataset);

The alert message block shows 0.20.40.60.8, and not as an array.

How would I fix this?

You could jsonify the dataset:

In [1]: import json

In [2]: json.dumps("[1,2,3]")
Out[2]: '"[1,2,3]"'

In [3]: bars = json.dumps("[1,2,3]")

In [4]: bars
Out[4]: '"[1,2,3]"'

... and then in the template just put the variable in the javascript code. Be aware that you migth need to surround the javascript code with

/*<![CDATA[*/
.
var dataset = ${bars}
.

/*]]>*/

To avoid missinterpretation from Genshi.


Pato


--
patoVala
Linux User#280504
Hablando en http://www.elprimoalcahuete.com
"The difference between a good haircut and a bad one is seven days."

--
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/turbogears?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to