checklist: replace inArray on loop with non-strict comparison

This commit is contained in:
vitalets
2012-11-29 22:05:40 +04:00
parent c3a3553b29
commit 518b2d88b1

@ -71,11 +71,17 @@ $(function(){
var $checks = this.$input.find('input[type="checkbox"]'); var $checks = this.$input.find('input[type="checkbox"]');
$checks.removeAttr('checked'); $checks.removeAttr('checked');
if($.isArray(value) && value.length) { if($.isArray(value) && value.length) {
$checks.each(function(i, el) { $checks.each(function(i, el) {
if($.inArray($(el).val(), value) !== -1) { var $el = $(el);
$(el).attr('checked', 'checked'); // cannot use $.inArray as it performs strict comparison
} $.each(value, function(j, val){
}); /*jslint eqeq: true*/
if($el.val() == val) {
/*jslint eqeq: false*/
$el.attr('checked', 'checked');
}
});
});
} }
}, },