I have a problem with my application regarding jQuery. I tried the sample code ( http://aspnet.4guysfromrolla.com/articles/120810-1.aspx ) to use the header control panel to check / clear all rows inside the GridView. The sample code works with jQuery v1.4.4, but does not work with the latest version of jQuery v1.9.0.
Here is the code.
<script type="text/javascript"> var allCheckBoxSelector = '#<%=gvFileList.ClientID%> input[id*="chkAll"]:checkbox'; var checkBoxSelector = '#<%=gvFileList.ClientID%> input[id*="chkSelected"]:checkbox'; function ToggleCheckUncheckAllOptionAsNeeded() { var totalCheckboxes = $(checkBoxSelector), checkedCheckboxes = totalCheckboxes.filter(":checked"), noCheckboxesAreChecked = (checkedCheckboxes.length === 0), allCheckboxesAreChecked = (totalCheckboxes.length === checkedCheckboxes.length); $(allCheckBoxSelector).attr('checked', allCheckboxesAreChecked); } $(document).ready(function () { $(allCheckBoxSelector).live('click', function () { $(checkBoxSelector).attr('checked', $(this).is(':checked')); ToggleCheckUncheckAllOptionAsNeeded(); }); $(checkBoxSelector).live('click', ToggleCheckUncheckAllOptionAsNeeded); ToggleCheckUncheckAllOptionAsNeeded(); }); </script>
With jQuery v1.4.4, everything works fine. Using jQuery v1.9.0 for each page load, I get "The object does not support this property or method: .live". If I use the syntax:
$(allCheckBoxSelector).click(function () {...
instead of the above, I avoid the error, but the header flag only works once. If I click on it again, nothing will be added.
I also tried the .on syntax:
$(allCheckBoxSelector).on('click', function () {...
but it doesnโt work either.
I would like to know if this issue is caused by a change or error in jQuery v1.9.0.
source share