I am facing a strange issue in my project. I have used KnockoutJS for creating my UI. I am using latest version of Android Cordova. I have defined an HTML input type number
in KnockoutJS
<input maxlength="3" type="number" data-bind="maxLength: maxLengthSeats" placeholder="seats" />
However, when I run my app on Android device, the numeric keypad opens but when I enter either 8 or 9, my app crashes. There are no errors or logs. The app just stops with a white screen and I see the home screen of my device.
Why is the problem coming? I tried creating a fresh new Cordova project and added just one input number which is working. So what's the issue with Knockout ?
Has anyone faced such a problem when using Knockout in combination with cordova?
//truncate value extender
ko.extenders.truncateValue = function(target, option) {
target.subscribe(function (newValue) {
if(newValue.length > option){
target(newValue.substring(0,option));
}
});
return target;
};
//maximum length extender
ko.bindingHandlers.maxLength = {
init: function (element, valueAccessor, allBindingsAccessor,
viewModel) {
'use strict';
var maxlength = element.getAttribute("maxlength");
valueAccessor().extend({truncateValue: maxlength })
ko.bindingHandlers.value.init(element, valueAccessor,
allBindingsAccessor, viewModel);
}
};