Your first issue is mainly due to the interaction with kendo.
The selector "input.cbSelect"
is not correct, since you are replacing the original checkboxes with label-only ones. So actually you are clicking on the label and not on the checkbox itself. The correct one would be "li label span"
but even then it wouldn't work because you cannot prevent kendo from selecting the panel.
Even
$("#panelbar").on("click", "label span", function(evt) {
evt.stopImmediatePropagation();
return false;
})
wouldn't prevent the kendo selection.
But what you actually can do is unbinding the child from the parent with a html action, so the kendo handler doesn't trigger:
Solution:
In your template replace
<span id='cbSelect" + x + "'></span>
with
<a href="#" id='cbSelect" + x + "'></a>
and in your input css the span
with a
.
The a-Element triggers a seperate action, so now you can stop the kendo Handler with
$("#panelbar").on("click", "label a", function(evt) {
evt.stopImmediatePropagation();
});
The problem now is, that the checking of the checkbox by clicking on the label also doesn't work. So we have to do this manually by extending the handler above:
$("#panelbar").on("click", "label a", function(evt) {
var chkbx = $(this).closest('li').find('input');
chkbx.prop('checked', !chkbx.prop('checked'));
evt.stopImmediatePropagation();
})
Working example:
http://jsfiddle.net/Nitro3k/5nX8r/47/
Alternative:
If you do not want the link inside the label, you can also:
- remove the span completely, style the label directly instead and call
return false;
instead ofevt.stopImmediatePropagation();
- build a custom checkbox, since you have to trigger it with
js
anyway:
Remove the lable, style a block instead (e.g .checkbox
) together with a checked class (e.g. .checkbox.checked
).
Build the block around the checkbox:
<div class="checkbox"><input type='checkbox' id='c1' class='cbSelect' /></div>
and add the handler:
$(document).on('click', '.checkbox', function(){
var chkbx = $(this).find('input');
chkbx.prop('checked', !chkbx.prop('checked'));
$(this).toggleClass('checked');
})