I'm currently trying to fill jquery-templates that I get by using an ajax get on another folder on the server. I wanted to fill the responseTexts i get via .tmpl({..}). Sadly that didn't work. Here's what i do.
var a = $.ajax({
method: 'GET',
url : 'TemplateUrl/template.html'
});
$.when(a).done(function(){
$(a.responseText).tmpl({...});
});
The responseText is a very simple piece of html from a SharePoint Site looking like this
"<div>
<td class="ms-formbody">
<!-- FieldName="{{html FieldName}}"
FieldInternalName = "{{html FieldName}}"
FieldType = "SPFieldText" -->
{{html Text}}
</td>
</div>"
When trying to fill the template i get this
Uncaught TypeError: Failed to construct 'Text': Please use the 'new' operator, this DOM object constructor cannot be called as a function.
Maybe you guys have an idea. Would be great. Thanks in advance and
Greetings Chris
Ok the answer wasn't that hard and pretty logical once I had it. The template-engine needs the script-wrapper to work properly. So the html needs to look like this
<script type="text/x-jQuery-tmpl">
<div>
<td class="ms-formbody">
<!-- FieldName="{{html FieldName}}"
FieldInternalName = "{{html FieldName}}"
FieldType = "SPFieldText" -->
{{html Text}}
</td>
</div>
</script>