admin管理员组文章数量:1419225
Is there a way to use an ko.observableArray like a map/dictionary?
For example:
var arr = ko.observableArray();
arr.push('key', { '.. Some object as value ..' });
And then retrive the value using the key:
var value = arr['key'];
Is there a way to use an ko.observableArray like a map/dictionary?
For example:
var arr = ko.observableArray();
arr.push('key', { '.. Some object as value ..' });
And then retrive the value using the key:
var value = arr['key'];
Share
Improve this question
asked Oct 21, 2012 at 11:21
MichaelSMichaelS
7,14310 gold badges53 silver badges75 bronze badges
2
- Have you checked out this guy's dictionary implementation? github./jamesfoster/knockout.observableDictionary – Tom W Hall Commented Oct 21, 2012 at 11:34
- @TomHall: Thanks for the link, it looks good. I've found another more naive implementation: wiredprairie.us/blog/index.php/archives/1563 – MichaelS Commented Oct 21, 2012 at 11:37
1 Answer
Reset to default 3Found two possible implementations:
- James Foster / knockout.observableDictionary - It has everything a dictionary needs. (Thanks to Tom Hall for the great find)
- A more naive implantation - suits the basic needs.
I ended up using the observableDictionary, it is fast and simple.
本文标签: javascriptIs there a way to use koobservableArray as mapStack Overflow
版权声明:本文标题:javascript - Is there a way to use ko.observableArray as map? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745301806a2652412.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论