@@ -10,13 +10,13 @@ export default function initMarkdownCheckboxes() {
1010 const $segment = $ ( segment ) ;
1111 const $checkboxes = $segment . find ( '.render-content.markdown input:checkbox' ) ;
1212
13- const onChange = async ( ev , cbIndex ) => {
14- const $cb = $ ( ev . target ) ;
15- const checkboxMarkdown = $cb . is ( ':checked' ) ? '[x]' : '[ ]' ;
13+ const onChange = async ( ev , checkboxIndex ) => {
14+ const $checkbox = $ ( ev . target ) ;
15+ const checkboxMarkdown = $checkbox . is ( ':checked' ) ? '[x]' : '[ ]' ;
1616
1717 const $rawContent = $segment . find ( '.raw-content' ) ;
1818 const oldContent = $rawContent . text ( ) ;
19- const newContent = oldContent . replace ( checkboxMarkdownPattern , replaceNthMatchWith ( cbIndex , checkboxMarkdown ) ) ;
19+ const newContent = oldContent . replace ( checkboxMarkdownPattern , replaceNthMatchWith ( checkboxIndex , checkboxMarkdown ) ) ;
2020
2121 if ( newContent !== oldContent ) {
2222 disableAll ( $checkboxes ) ;
@@ -28,7 +28,7 @@ export default function initMarkdownCheckboxes() {
2828 await submit ( newContent , url , context ) ;
2929 $rawContent . text ( newContent ) ;
3030 } catch ( e ) {
31- $cb . prop ( 'checked' , ! $cb . is ( ':checked' ) ) ;
31+ $checkbox . prop ( 'checked' , ! $checkbox . is ( ':checked' ) ) ;
3232
3333 console . error ( e ) ;
3434 } finally {
@@ -38,8 +38,8 @@ export default function initMarkdownCheckboxes() {
3838 } ;
3939
4040 enableAll ( $checkboxes ) ;
41- $checkboxes . each ( ( cbIndex , cb ) => {
42- $ ( cb ) . on ( 'change' , ( ev ) => onChange ( ev , cbIndex ) ) ;
41+ $checkboxes . each ( ( checkboxIndex , checkboxElement ) => {
42+ $ ( checkboxElement ) . on ( 'change' , ( ev ) => onChange ( ev , checkboxIndex ) ) ;
4343 } ) ;
4444 } ) ;
4545}
0 commit comments