Make Knockout Applybindings To Treat Select Options As Number May 30, 2023 Post a Comment Im using Knockout in combination with html select / option (see Fiddle): 10100Solution 1: You can try something likeself.Width = ko.observable(10); self.Width.subscribe(function(newValue){ if(typeof newValue === "string"){ self.Width(parseInt(newValue)); } }); CopySolution 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"