【问题标题】:knockout.js not working with jquery template propertyknockout.js 不使用 jquery 模板属性
【发布时间】:2011-09-03 20:37:13
【问题描述】:

我不确定发生了什么,但我想在 jquery 模板中将“Route”属性传递给我的函数,但它总是以带有 $index、$data 的数组的形式出现,并且 $Route 表示它可以找不到。我让它工作的唯一方法是使用下面的模板。我宁愿这样做<a href="" data-bind="attr: { href: app.viewModel.members.createRoute($Route) }">${Title}</a>

我正在使用 jquery 1.3 beta 和 jquery template 1.0.0pre。

<script id="actionsTemplate" type="text/html">
    {{each $data}}
    {{if $index == 0}}
        <li style="float: left">
            <h1 data-bind="html: app.viewModel.members.page.title"></h1>
        </li>
    {{/if}}

    <li>
        <a href="" data-bind="attr: { href: app.viewModel.members.createRoute($data[$index].Route) }">${Title}</a>
    </li>
    {{/each}}
</script>

【问题讨论】:

  • 你是尝试Route(所以,不是$Route)还是$data.Route(相同)?
  • 天哪。发表你的答案,我会标记它是正确的。

标签: jquery knockout.js jquery-templates


【解决方案1】:

看起来你想使用Route(所以不是$Route)或$data.Route(同样的事情)。

【讨论】:

    猜你喜欢
    • 2011-10-24
    • 1970-01-01
    • 1970-01-01
    • 2011-11-18
    • 2011-10-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多