Reputation: 4126
I keep getting same error every time i try to load my jQuery template. On document ready i get list of Items as a json list, and on succes this code run:
function add(result) {
var panel = $('#MainContent_Panel1');
for (var k = 0; k < result.d.length; k++) {
$("#template").tmpl(result.d[k]).appendTo("#MainContent_Panel1");
}
}
Here is my Template :
<script id="template" type="text/x-jquery-tmpl" >
<div id ="myID" style="background-color: red">
<span questionLabelGroup="$i">Question : ${Uid}</span>
<span questionTextGroup="$i">Hello ${Content}<br /></span>
<span answerLabelGroup="$i">Answer : </span>
<input type='text' questionID="$guid"/>
<input type='button' Class='addAnswerButton' addQuestionButtonGroup='"$i"' value='Add Question' />
<hr />
</div>
</script>
and i keep getting this error: TypeError: $("#template").tmpl is not a function. Any ideas what i did wrong?
Upvotes: 0
Views: 161
Reputation: 14044
It sounds like the jquery template plugin might not be loaded. have you included the script tag loading the plug-in? if so, is it being loaded before the snippet of code in your example is being executed?
Upvotes: 3