I have a mobile web app that works fine on iOS and 4 of 7 Android devices we've tested, but on 3 of them, all <4.4(kitkat) the checkboxes cannot be checked. It "bounces" like a double-tap has happened so the box checks then unchecks immediately. Again, on everything else, it checks fine. I've rewritten it once to simply the bindings and upgraded from KO 2.0 to 3.0, but still have the issue. It did get a little "better" in that now I can check using the white square itself, but if I tap on the text of the label, it does the check/uncheck bounce like always.
At this point, I'm stuck and need some more expert eyes to see what I'm doing wrong or tell me if it's an Android issue that I've not been able to find on the web.
Here is the pertinent code starting with subset of the HTML:
<ul class="checkradio">
<li><label for="box1" data-bind="css: { dis: viewModel.boxGrayed('value1', viewModel.box1.id()) }"><input id="box1" value="value1" type="checkbox" data-bind="checked: viewModel.pickList" />Item One<span data-bind="text: boxOrderNums.firstPickOrder"></span></label><span class="arrow jump" data-bind="visible: boxGrayed('value1', viewModel.box1.id()), click: function() { alert('destOne'); }">Go to</span></li>
<li><label for="box2" data-bind="css: { dis: viewModel.boxGrayed('value2', viewModel.box2.id()) }"><input id="box2" value="value2" type="checkbox" data-bind="checked: viewModel.pickList" />Item Two<span data-bind="text: boxOrderNums.secondPickOrder"></span></label><span class="arrow jump" data-bind="visible: boxGrayed('value2', viewModel.box2.id()), click: function() { alert('destTwo'); }">Go to</span></li>
</ul>
Here is the JS:
var viewModel = {
pickList: ko.observableArray([]),
boxOrderNums: {
firstPickOrder: ko.observable(""),
secondPickOrder: ko.observable("")
},
box1 = new Box(),
box2 = new Box()
};
viewModel.boxGrayed = function(st, stid) {
return $.inArray(st, this.pickList()) !== -1 && stid > 0;
}.bind(viewModel);
// in real life, this is a complex object in different file with prototyped methods, etc.
function Box()
{
this.id = ko.observable(0);
}
// fake the AJAX data
$(document).ready(function() {
viewModel.box1.id(101);
viewModel.box2.id(201);
});
CSS to style the checkboxes for mobile:
input[type=checkbox] {
width: 22px;
height: 21px;
display: inline-block;
-webkit-appearance: none;
border: 1px solid black;
margin-top: -2px;
}
input[type=checkbox]:checked {
background: green; /* in real life, this is a checkmark image url */
}
input[type=checkbox]:disabled {
opacity: 0.3;
}
.checkradio label {
vertical-align: top;
padding: 2px 0 0 2px;
}
.checkradio label span {
vertical-align: top;
}
I'd setup a fiddle but didn't know how to make it mobile friendly. Please help.