Make Knockout ApplyBindings To Treat Select Options As Number October 28, 2022 Post a Comment Im using Knockout in combination with html select / option (see Fiddle): 10 100 Solution 1: You can try something like self.Width = ko.observable(10); self.Width.subscribe(function(newValue){ if(typeof newValue === "string"){ self.Width(parseInt(newValue)); } }); Copy Solution 2: You can make Width as computed and write own "write" and "read" options like that: var _width = ko.observable(10); self.Width = ko.computed({ read : function(){ return _width; }, write: function(value){ if(typeof value === "string"){ _width(parseInt(value)); } } Copy Share Post a Comment for "Make Knockout ApplyBindings To Treat Select Options As Number"
Post a Comment for "Make Knockout ApplyBindings To Treat Select Options As Number"