Skip to content Skip to sidebar Skip to footer

Knockout.js: No Concat On Observablearray

Only starting with knockout.js, but already running into some trouble when trying to make a computed method based on 2 different observableArrays Using the documentation on knockou

Solution 1:

Change:

this.Products().concat(this.Products2()),

to:

self.Products().concat(self.Products2()),

Inside your TotalAmount ko.computed function.

this in the context of your computed refers to the global object rather than the view model. So you need to use the self variable that is assigned the correct this value earlier.

Working Example - http://jsfiddle.net/55kZp/

Solution 2:

concat didn't works for me .. I did push

self.Products.push.apply( 
  self.Products, self.Products2()
);

Post a Comment for "Knockout.js: No Concat On Observablearray"