assets/index.js
function Dictionary(data) {
    this.items = ko.observableArray([]);
    for (var field in data) {
        if (data.hasOwnProperty(field)) {
            this.items.push(new DictionaryItem(field, data[field]));
        }
    }

    this.addItem = function() {
        this.items.push(new DictionaryItem());
    }.bind(this);

    this.removeItem = function(item) {
        this.items.remove(item);
    }.bind(this);

    this.itemsAsObject = ko.dependentObservable(function() {
        var result = {};
        ko.utils.arrayForEach(this.items(), function(item) {
            result[item.key()] = item.value;
        });

        return result;
    }, this);
}
function Dictionary(data) {
    this.items = ko.observableArray([]);
    for (var field in data) {
        if (data.hasOwnProperty(field)) {
            this.items.push(new DictionaryItem(field, data[field]));
        }
    }

    this.addItem = function() {
        this.items.push(new DictionaryItem());
    }.bind(this);

    this.removeItem = function(item) {
        this.items.remove(item);
    }.bind(this);

    this.itemsAsObject = ko.dependentObservable(function() {
        var result = {};
        ko.utils.arrayForEach(this.items(), function(item) {
            result[item.key()] = item.value;
        });

        return result;
    }, this);
}
function Dictionary ( data ) { this . items = ko . observableArray ( [ ] ) ; for ( var field in data ) { if ( data . hasOwnProperty ( field ) ) { this . items . push ( new DictionaryItem ( field , data [ field ] ) ) ; } } this . addItem = function ( ) { this . items . push ( new DictionaryItem ( ) ) ; } . bind ( this ) ; this . removeItem = function ( item ) { this . items . remove ( item ) ; } . bind ( this ) ; this . itemsAsObject = ko . dependentObservable ( function ( ) { var result = { } ; ko . utils . arrayForEach ( this . items ( ) , function ( item ) { result [ item . key ( ) ] = item . value ; } ) ; return result ; } , this ) ; }
Custom Dictionary observable in Knockout represent the dictionary object
Custom Dictionary observable in Knockout represent the dictionary object