Extending knockout observable array

前端 未结 1 703
野性不改
野性不改 2021-02-20 03:04

I\'d like to add some \"ArrayCollection\" like functionality to a ko.observableArray();

i.e removeItemAt(index)//dispatches item removed event addItem(item)//dispatches

相关标签:
1条回答
  • 2021-02-20 03:40

    Extending observableArrays is easy and a perfectly reasonable thing to do.

    The easiest way to accomplish this is to add functions to ko.observableArray.fn. There is now a documentation page for this technique.

    This is a little bit different than what you are after, but here is a nice implementation of a dictionary in ko that may be of interest to you: https://github.com/jamesfoster/knockout.observableDictionary

    0 讨论(0)
提交回复
热议问题