Skip to content

Commit 1608f3c

Browse files
committed
Fix to use jQuery's prop rather than attr method
Needed to remain compatible with versions of jQuery from 1.6 onwards.
1 parent 4c31f45 commit 1608f3c

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

jquery.checktree.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,17 +84,17 @@ jQuery.fn.checkTree = function(settings) {
8484
$this
8585
.toggleClass('checked')
8686
.removeClass('half_checked')
87-
.siblings(':checkbox:first').attr('checked', $this.hasClass('checked') ? 'checked' : '')
87+
.siblings(':checkbox:first').prop('checked', $this.hasClass('checked'))
8888
;
8989

9090
$this.filter('.checked').siblings('ul:first').find('.checkbox:not(.checked)')
9191
.removeClass('half_checked')
9292
.addClass('checked')
93-
.siblings(':checkbox').attr('checked', 'checked')
93+
.siblings(':checkbox').prop('checked', true)
9494
;
9595
$this.filter(':not(.checked)').siblings('ul:first').find('.checkbox.checked')
9696
.removeClass('checked half_checked')
97-
.siblings(':checkbox').attr('checked', '')
97+
.siblings(':checkbox').prop('checked', false)
9898
;
9999

100100
// Send a change event to our parent checkbox:
@@ -121,7 +121,7 @@ jQuery.fn.checkTree = function(settings) {
121121
var any_unchecked = $this.siblings('ul:first').find(':checkbox:not(:checked):first').length == 1;
122122

123123
if (any_checked) {
124-
$this.attr('checked', 'checked');
124+
$this.prop('checked', true);
125125
if (any_unchecked) {
126126
$checkbox
127127
.addClass('half_checked')
@@ -140,7 +140,7 @@ jQuery.fn.checkTree = function(settings) {
140140
}
141141
else {
142142
$checkbox.removeClass('checked half_checked');
143-
$this.attr('checked', '');
143+
$this.prop('checked', false);
144144
}
145145
});
146146

@@ -181,7 +181,7 @@ jQuery.fn.checkTree = function(settings) {
181181
$tree.clear = function() {
182182
$tree.find('.checkbox')
183183
.removeClass('checked')
184-
.siblings(':checkbox').attr('checked', '')
184+
.siblings(':checkbox').prop('checked', false)
185185
;
186186
};
187187
};

0 commit comments

Comments
 (0)