Reputation: 45
Im generating some pictures dynamically:
<#list content.templates as template>
<td>
<img class="event_template" title="${template.getTemplateName()}" id="${template.getTemplateName()}" src="${template.getTemplatePicturePath()}" width="170px" height="140px"/>
</td>
</#list>
In my javascript file, i want to get all of these pictures ids in an array, to use jQuery function etc. on them.
I tried the following:
var templates = [<#list content.templates as temp>$("#"+${temp.getTemplateName()}),</#list>];
But i got an error:
Uncaught Error: Syntax error, unrecognized expression: #[object HTMLImageElement]
(jquery-1.8.2.min.js:2)
Do anyone get a clue what's wrong? Thanks!
Upvotes: 1
Views: 1564
Reputation: 9319
Well, there's your problem: You put the templateName outside the quotes, but it needs to be a string.
Solution:
... $("#${temp.getTemplateName()}") ...
Upvotes: 2