我将json从ajax传递到kendo模板,接下来我需要在模板中设置输入值。我试过这个:
$.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# />
如果属性包含多个单词,则模板首先设置...例如,如果Text_Value =&#34;测试值&#34; ......输入值仅为&#34;测试&#34; ...
我尝试在模板中打印控制台对象数据,它没问题。所以我不知道它有什么问题。
有人可以帮我解决吗?
答案 0 :(得分:0)
你需要用“”这样的标记包住它:
<?= Html::dropDownLIst('assign_to', null,
['1' => 'Admin'] + ArrayHelper::map(PhCrmUser::findAll(['user_type' => 'executive_manager', 'status' => CrmUser::STATUS_ACTIVE]), 'id',
function($model, $defaultValue) {
return $model['first_name']." ".$model['last_name'];
}
),
['class' => 'form-control', 'prompt' => 'Assign to Manager']
)?>
因为您的代码生成了无效的HTML,如:
<input id="myInput" class="form-control" value="#= data.Text_Value#" />