Created
September 27, 2012 11:40
-
-
Save ova2/3793573 to your computer and use it in GitHub Desktop.
Solution to "DataTable performance problem in IE with checkboxes / radio buttons"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bindCheckboxEvents: function() { | |
... | |
SOLUTION TO THE PERFORMANCE PROBLEM | |
//keyboard support | |
$(checkboxSelector).off('focus.ui-chkbox blur.ui-chkbox keydown.ui-chkbox keyup.ui-chkbox') | |
.on('focus.ui-chkbox', function() { | |
var input = $(this), | |
box = input.parent().next(); | |
if(input.prop('checked')) { | |
box.removeClass('ui-state-active'); | |
} | |
box.addClass('ui-state-focus'); | |
}) | |
.on('blur.ui-chkbox', function() { | |
var input = $(this), | |
box = input.parent().next(); | |
if(input.prop('checked')) { | |
box.addClass('ui-state-active'); | |
} | |
box.removeClass('ui-state-focus'); | |
}) | |
.on('keydown.ui-chkbox', function(e) { | |
var keyCode = $.ui.keyCode; | |
if(e.which == keyCode.SPACE) { | |
e.preventDefault(); | |
} | |
}) | |
.on('keyup.ui-chkbox', function(e) { | |
var keyCode = $.ui.keyCode; | |
if(e.which == keyCode.SPACE) { | |
var input = $(this), | |
box = input.parent().next(); | |
if(input.prop('checked')) { | |
_self.unselectRowWithCheckbox(box); | |
} | |
else { | |
_self.selectRowWithCheckbox(box); | |
} | |
e.preventDefault(); | |
} | |
}); | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
======== Using with .find() as example for custom events binding
======== Tip to using without .off(). It's working well with AJAX updates and avoid multiple binding