本文介绍了没有插入Durandal/淘汰赛模板绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我当前正在尝试将表行<tr>模板传播到<tbody>标记中.这是一个示例:

I am currently trying to propagate a table row <tr> template into a <tbody> tag. Here is an example:

HTML:

<table>
    <tbody data-bind="template: { name : 'tableTemplate', foreach : tableRow }">
    </tbody>
</table>
<script type="text/html" id="tableTemplate">
    <tr>
        <!-- First Name -->
        <td data-bind="text: firstName"></td>
        <!-- Last Name -->
        <td data-bind="text: lastName"></td>
    </tr>
</script>

DurandalJS:

DurandalJS:

define(function(require) {
    var self = this;
    self.app = require('durandal/app');

    return {
       tableRow: ko.observableArray([
           { firstName: "DemoFirstName" , lastName: "ExampleLastName" },
           { firstName: "ExampleFirstName", lastName: "DemoLastName" }
       ]);

    //viewAttached and other non-applicable console log functions here
    };
});

HTML中的所有内容都将正确地进行数据绑定,直到命中表格为止;之后所有数据绑定都将失效.

Everything in the HTML will properly data-bind until it hits the table; all data-binds afterwards become dead.

我对杜兰达(Durandal)相当陌生,并且我正在学习.

I am rather new to Durandal, and am learning as I go.

推荐答案

我遇到了同样的问题,我在Durandal google小组上找到了答案.我将结果发布在我的问题上. KO无法找到具有ID的模板

I ran into the same problem, and I dug up the answer on the Durandal google group. I posted the results here on my question. KO cannot find template with ID

基本上,您还不能使用已命名/ID的Knockout模板,尚不支持它们.根据Durandal开发人员在其新闻组上的说法,支持可能会很快到来.解决方法是使用内联或Durandal的撰写功能.

Basically you can't use named/ID'd Knockout templates yet, they're not supported.Support may come soon, according to the Durandal devs on their newsgroup.The workaround is to use either inline, or Durandal's compose functionality.

这篇关于没有插入Durandal/淘汰赛模板绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-12 12:32