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

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -