Fiddle http://jsfiddle.net/hdD8B/
I'm having trouble replacing this code that worked in jQuery 1.7.
I have a button that simply checks all the checkboxes when clicked and then unchecks them when clicked again.
$('.check:button').toggle(
function () {
$('input:checkbox').attr('checked', 'checked');
$(this).val('uncheck all');
}, function () {
$('input:checkbox').removeAttr('checked');
$(this).val('check all');
});
this is the closest I have been able to get it works to check and uncheck all once then doesn't work anymore. It also seems kind of ugly to have to a simple method replaced with a more complicated on.
(function ($) {
$.fn.clickToggle = function (func1, func2) {
var funcs = [func1, func2];
this.data('toggleclicked', 0);
this.click(function () {
var data = $(this).data();
var tc = data.toggleclicked;
$.proxy(funcs[tc], this)();
data.toggleclicked = (tc + 1) % 2;
});
return this;
};
}(jQuery));
/*global $, jQuery,document,fnCreateSelect*/
$(document).ready(function () {
$('.check:button').clickToggle(
function () {
$('input:checkbox').attr('checked', 'checked');
$(this).val('uncheck all');
}, function () {
$('input:checkbox').removeAttr('checked');
$(this).val('check all');
});