File tree Expand file tree Collapse file tree 3 files changed +9
-16
lines changed Expand file tree Collapse file tree 3 files changed +9
-16
lines changed Original file line number Diff line number Diff line change 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 } ;
You can’t perform that action at this time.
0 commit comments