【问题标题】:Kendo, basic template binding剑道,基本模板绑定
【发布时间】:2014-11-20 12:25:07
【问题描述】:

也许我误解了文档,但我认为我可以做到这一点,但显然我不能......

http://jsfiddle.net/dh2b835m/1/

<script id="editor" type="text/x-kendo-template">
    <h2>Object Id: #: data.id #</h2>
</script>

<div id="component" 
     data-bind="source: model" 
     data-template="editor" 
/>

<script>
   $(function() {
     var model = new kendo.observable({ id: 'test' });
     var component = $("#component");
     kendo.bind(component, model);
   });
</script>

我在这里错过了什么?

【问题讨论】:

    标签: javascript data-binding kendo-ui kendo-template


    【解决方案1】:

    您的 data-bind="source: model" 需要模型中的元素 model

    同样在模板中data.id 可能会丢失data.

    查看编辑后的jsfiddle

    看到这个kendo documentation

    【讨论】:

      【解决方案2】:

      好吧,原来文档没有提到这一点,但你应该在以这种方式绑定根时使用它...

      <div id="component" 
           data-bind="source: this" 
           data-template="editor" 
      />
      

      所做的一切(在解决了这个问题之后)只是提出了更多的问题......太好了!

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2015-01-19
        • 1970-01-01
        • 1970-01-01
        • 2015-08-19
        • 1970-01-01
        • 1970-01-01
        • 2023-03-30
        • 1970-01-01
        相关资源
        最近更新 更多