如何使用Kendo UI模板替换jQuery的AppendTo?

时间:2014-08-26 03:09:45

标签: templates kendo-ui

现在我使用jQuery的AppendTo方法将一个字符串元素添加到div的输入中:

var fixedpricePanelDiv = 
'<label class="control-label">Fixed price: </label>'
+'<input id="cakpriceNum" name="cakcommitprice[cakprice]" type="number"/>'
+'<input id="cakpriceunitidDdl" name="cakcommitprice[cakpriceunitid]" />';
$(fixedpricePanelDiv).appendTo($("#panel"));

<div id="panel"></div>

如果我现在更改为KendoUI模板,该怎么做?

2 个答案:

答案 0 :(得分:0)

流畅的

<div id="example"></div>
        <script>
            var template = kendo.template('<label class="control-label">Fixed price: </label>'+'<input id="cakpriceNum" name="#= cakprice#" type="number"/>'+'<input id="cakpriceunitidDdl" name="#= cakpriceunitid#" />');

            var data = { cakpriceunitid: "some val",cakprice:"some val" }; //A value in JavaScript/JSON
            var result = template(data); /Pass the data to the compiled template
            $("#example").html(result); //display the result
        </script>

更多信息请查看文档http://docs.telerik.com/kendo-ui/getting-started/framework/templates/overview

答案 1 :(得分:0)

自从剑道文件的研究以来,我认为kendo.view用于此目的