21278 Posts in 5728 Topics by 2599 members
General Questions
SilverStripe Forums » General Questions » Send values to javascript within a template control block
General questions about getting started with SilverStripe that don't fit in any of the categories above.
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 309 Views |
-
Send values to javascript within a template control block

2 December 2011 at 12:05pm Last edited: 2 December 2011 12:06pm
Hi, I am trying dynamically push values from a Page Control into some inline JavaScript in a .ss Template as such:
<% control MyControl %>
<script>my_javascript_array.push($MyControlValue)</script>
<% end_control %>The JavaScript that gets outputted to HTML is:
<script>my_javascript_array.push()</script>
That is, all values come out blank. I know this control has data because if I remove the script tags within the control block the values appear in the HTML fine.
Is what I am trying to do possible?? If so, what am I doing wrong?
-
Re: Send values to javascript within a template control block

3 December 2011 at 2:31pm
So do you mean if you take off the script tags then the value gets printed, if so a work around solution will be to add those scrip tags out of the <% control %> block.
Out of question don't you need quotes around the argument you pass to the js push method?
| 309 Views | ||
|
Page:
1
|
Go to Top |


