Reputation: 9634
i have got the json data in my js file and now i need to pass the same to jtemplate and display. Here is the code i tried, but no data is getting displayed
$.ajax({
url: '/CMananager/getDetails',
contentType: "application/json; charset=utf-8",
data: { 'ID': ID },
type: 'GET',
cache: false,
success: function (result) {
var placeHolder = $("#templatePlaceHolder");
placeHolder.setTemplateURL("/Templates/Preview/Details.htm");
placeHolder.processTemplate(result.Name);
}
In jtemplate i'm trying to read the data like this, nothing is getting displayed
<input type="text" id="Details" name="DetailsName" style="float:left; font-size:14px; line-height:42px; padding: 0; text-align: left;width: 80%;" value="{$T.Name}" maxlength="50"/>
<span id="DetailsNamespan" style="float:left; font-size:14px; line-height:42px; padding: 0; text-align: left;width: 80%;">{$T.Name}</span>
Upvotes: 2
Views: 420
Reputation: 139768
$T
references the data object what you pass in to the template.
So if you want to reference your data with {$T.Name}
then you need to pass in an object which has a Name
property:
placeHolder.processTemplate({Name: result.Name});
Or if you only want to pass in a simple type (string, number, etc) you can do it but in this case you need to use {$T}
to access it in the template:
placeHolder.processTemplate(result.Name);
And in your template:
<input type="text" id="Details" name="DetailsName" value="{$T}" />
<span id="DetailsNamespan">{$T}</span>
Upvotes: 4