knockout.js - Subscribe doesn't work with Knockout Model as function -


i think i'm struggling basics here. code:

var vehiclesearchviewmodel = function() {    this.vehiclevariantid = ko.observable(0);    this.vehiclevariantid.subscribe(function (id) {       console.log(id);   }); }; 

from function outside of this, following:

vehiclesearchviewmodel.vehiclevariantid = 777; 

...and console.log doesn't fire. albeit if type vehiclesearchviewmodel.vehiclevariantid in console can see it's been updated new value. what's right way of doing this?

knockout observables functions. need set them passing new value parameter.

vehiclesearchviewmodel.vehiclevariantid(777);

you should go through the tutorials, going have lot of questions can answered them.


Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

monitor web browser programmatically in Android? -

c# - Using multiple datasets in RDLC -