Skip to content

Commit 19dac48

Browse files
committed
fixed checkbox js
1 parent 446de0f commit 19dac48

File tree

3 files changed

+9
-16
lines changed

3 files changed

+9
-16
lines changed

assets/js/csf.js

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2281,20 +2281,13 @@
22812281
$.fn.csf_checkbox = function() {
22822282
return this.each( function() {
22832283

2284-
var $this = $(this);
2285-
var value = 0;
2286-
var $input = $this.find('.csf--input');
2287-
var $checkbox = $this.find('.csf--checkbox');
2288-
2289-
if( $input.val() === '1' ) {
2290-
value = 0;
2291-
$checkbox.prop('checked', false);
2292-
} else {
2293-
value = 1;
2294-
$checkbox.prop('checked', true);
2295-
}
2284+
var $this = $(this),
2285+
$input = $this.find('.csf--input'),
2286+
$checkbox = $this.find('.csf--checkbox');
22962287

2297-
$input.val(value).trigger('change');
2288+
$checkbox.on('click', function() {
2289+
$input.val( Number( $checkbox.prop('checked') ) ).trigger('change');
2290+
});
22982291

22992292
});
23002293
};

0 commit comments

Comments
 (0)