How do I use jQuery functions in a custom knockout extender. Here is an example of adding a class to a knockout target from a custom extender.
ko.extenders.addClass = function(target, option) {
if (option == true)
{
target.subscribe(function(newValue) {
$(this.target).addClass('new_class');
});
}
return target;
}
Combine a normal dirty-flag with the css-binding.
You could also pass an observable, or an array of observables, if you want to track just a subset of the properties.
http://jsfiddle.net/MizardX/7esdy/