I have a template as below:

<script type="text/template" id="editorItemPlacholder">

And create an instance of the template like this:

var editorItemTemplate = $("#editorItemPlacholder").html();

then i want to change the id of an element inside the template, each time i make an instance of it. So i think i must use this:


but this doesn't work. And the sign is that the code doesn't go after this line. What is wrong with this type of selection? how can i make change in that template. thanks all.

1 Answers

Mario Araque On

You are using a jQuery function in a html element. You can not use find into $editorItemTemplate, which contains the html of the template.

You have to find the element using this way:

$('div', $editorItemTemplate).prop('id', item);