javascript - Is there a way to use ko.observableArray as map? - Stack Overflow

Is there a way to use an ko.observableArray like a mapdictionary?For example:var arr = ko.observableAr

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
Add a ment  | 

1 Answer 1

Reset to default 3

Found two possible implementations:

  1. James Foster / knockout.observableDictionary - It has everything a dictionary needs. (Thanks to Tom Hall for the great find)
  2. 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条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信