I pass json into kendo template from ajax, and next i need set value of my inputs in template. I'm trying this:
$.ajax({
async: false,
type: "POST",
url: "/Service/MyService.svc/GetTestObjects",
data: '{"objectID": ' + '"' + myVal + '"}',
contentType: "application/json; charset=utf-8",
dataType: "json",
processdata: true,
success: function (msg) {
var template = kendo.template($("#myTemplate").html());
var templateView = template(msg.GetTestObjects);
$("#myContainer").html(templateView);
},
error: function (msg) {
console.log(msg)
}
});
<input id="myInput" class="form-control" value=#= data.Text_Value# />
and if property contains more than one word, template set only first ... for example if Text_Value = "test value" ... inputs value is only "test" ...
i tried print in console object data from template and it's OK. So I dont have idea what is wrong with it.
Can anyone help me fix it ?
You need to encase it in "" marks like this:
<input id="myInput" class="form-control" value="#= data.Text_Value#" />
Because your code is generating invalid HTML like:
<input id="myInput" class="form-control" value=test value />