Questions tagged «jquery-templates»

2
击倒.js中$ parent的访问索引
在基因敲除(snockout.js)2.1.0中,在使用foreach绑定的模板中,您可以通过$ index()函数访问当前项目的索引。在嵌套的foreach绑定中,是否有任何方法可以从模板访问$ parent的索引? 说我有一个像这样的数据结构: var application = { topModel: [ { {subModel: [{'foo':'foo'}, { 'bar':'bar'}]}, // this has top:0 and sub:0 {subModel: [{'foo2':'foo2'}, { 'bar2':'bar2'}]} // this has top:0 and sub:1 }, { {subModel: [{'foo':'foo'}, { 'bar':'bar'}]} // this is top:1 sub:0 }, { {subModel: [{'foo':'foo'}, { 'bar':'bar'}]} // this …

2
绑定到简单的字符串数组
如果我想将模板绑定到一个普通的旧字符串数组,我该在$ {??}表达式中放什么? 我希望这段代码不要太短,以免引起混淆: <ul data-bind="template: { name: 'authorTemplate', foreach: authors }"> </ul> 作者在哪里 ["a", "b", "c"] <script type="text/x-jquery-tmpl" id="authorTemplate"> <li>${what_do_I_put_here???}</li> </script> 我试过了:val value this和this.toString()。最后两个显示了[object Object],所以我怀疑我离那儿很近。
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.