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.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745301807a4621477.html
评论列表(0条)