I am trying to use knockbackjs (knockoutjs + backbonejs) where the model is a 2d array )ie table, and the viewModel is binded using foreach to a table html tag, so I will get an observable table, each click on a cell will send the entire 2d array to the api.
I've been looking at this and that examples with a question I've asked and got to something like this:
//model
var GameModel = Backbone.Model.extend({ urlRoot: '/game' });
//viewmodel
var GameViewModel = function (game) {
this.board = kb.observable(game, [
[ko.observable(0), ko.observable(0), ko.observable(0)],
[ko.observable(0), ko.observable(0), ko.observable(0)],
[ko.observable(0), ko.observable(0), ko.observable(0)]
]);
};
var model = new GameModel({ id: 1 });
var gameViewModel = new GameViewModel(model);
ko.applyBindings(gameViewModel);
but I get ' Uncaught Observable: key is missing ' on the line starting with
this.board = kb.observable(game, [
How can I fix this? Is there a better way of achieving this?