access jelly variable inside <script> tag
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2015 08:36 PM
I have a UI Page that retrieves data like this:
<g:evaluate var='jvar_events' object='true'>
var dt = new Date(2015, 0, 15, 0,0,0,0);
var gr = new isUtils();
var events = gr.getArrayOfObjects('74ad1ff3c611227d01d25feac2af603f', dt);
events;
</g:evaluate>
That executes fine, and jvar_events is an array of objects (I confirmed this with a <j:forEach... loop.
I need to pass jvar_events to a jQuery function inside the <script></script> block.
<script>
var $j_custom = jQuery.noConflict(true);
$j_custom(document).ready(function () {
parm1:test,
parm2: test,
parm3: ${jvar_events}
</script>
I've tried ${jvar_events}, '$jvar_events}, neither works.
I've also tried executing this inside the <script> and using events as parm3:
var dt = new Date(2015, 0, 15, 0,0,0,0);
var gr = new isUtils();
var events = gr.getArrayOfObjects('74ad1ff3c611227d01d25feac2af603f', dt);
when I create the same array inside the <script> tags with javascript it works fine, so I must not be accessing the jelly variable properly.
I cannot find any valid Wiki or articles on the subject.
Any assistance would be greatly appreciated.
Kevin
- Labels:
-
User Interface (UI)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2015 09:21 PM
Have you tried "${jvar_events}"? Per me, this should give you the values
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2015 03:40 AM
As Kalaiarasan P said, "${jvar_events}" should work. Try this:
<script>
var events = "${jvar_events}";
var $j_custom = jQuery.noConflict(true);
$j_custom(document).ready(function () {
parm1: test,
parm2: test,
parm3: events
}
</script>
If this is not working, try to access it with jelly.jvar_events.
var events = jelly.var_events;
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2015 07:11 AM
I tried both suggested solution with no success,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2015 07:15 AM
can you try just logging the variable in your script to see if capturing the jelly variable is the problem?
either
console.log('${jvar_events}');
or even just alert it
alert('${jvar_events}');