KnockOut run function on value changed

javascript, knockout.js

Solution

You could subscribe to your enabled function, such as:

enabled.subscribe(function(newValue) {
   if(newValue) {  // Has focus

   } else { 
       // No focus
   }
});

Problem

Got simple viewModel: ``` function viewModel() { enabled: ko.observable(false); ... } ``` and some binding like: ``` <input data-bind="hasFocus: enabled" /> ``` and i want run some function on focus, and other on focus lost( or enabled = true/false) but run when value changes. Any help?

Original source