0
我每次尝试加载我的jQuery模板时都会收到相同的错误。 在文件准备好,我得到的项目作为一个JSON清单列表,并在更迭此代码运行:如何加载jQuery模板
function add(result) {
var panel = $('#MainContent_Panel1');
for (var k = 0; k < result.d.length; k++) {
$("#template").tmpl(result.d[k]).appendTo("#MainContent_Panel1");
}
}
这里是我的模板:
<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>
,我不断收到此错误:类型错误:$ (“#模板”)。tmpl不是函数。任何想法我做错了什么?
你确定你包含jQuery $ .tmpl()文件吗? – dSquared