This repository was archived by the owner on Oct 26, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +18
-9
lines changed
Expand file tree Collapse file tree 4 files changed +18
-9
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66
77## [ Unreleased]
88
9+ ### Changed
10+
11+ - ** Breaking** ` data-target="checkbox-select-all.checkboxAll" ` is now required.
12+ - ** Breaking** ` data-action="change->checkbox-select-all#toggle" ` has been be removed.
13+ ``` diff
14+ - <input type="checkbox" data-action="change->checkbox-select-all#toggle" />
15+ + <input type="checkbox" data-target="checkbox-select-all.checkboxAll" />
16+ ```
17+
918## [ 1.1.0] - 2020-10-29
1019
1120### Added
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ application.register("checkbox-select-all", CheckboxSelectAll)
3535 <tbody >
3636 <td class =" block" >
3737 <label >
38- <input type =" checkbox" data-target =" checkbox-select-all.checkboxAll" data-action = " change->checkbox-select-all#toggle " />
38+ <input type =" checkbox" data-target =" checkbox-select-all.checkboxAll" />
3939 <span >Select All / Deselect All</span >
4040 </label >
4141 </td >
@@ -104,7 +104,7 @@ In your view:
104104``` html
105105<%= form_with model: @user, data: { controller: 'checkbox-select-all' } do |f| %>
106106 <label >
107- <input type =" checkbox" data-target =" checkbox-select-all.checkboxAll" data-action = " change->checkbox-select-all#toggle " />
107+ <input type =" checkbox" data-target =" checkbox-select-all.checkboxAll" />
108108 <span >Select All / Deselect All</span >
109109 </label >
110110
Original file line number Diff line number Diff line change @@ -98,12 +98,7 @@ <h2 class="text-center text-2xl font-bold my-4">Essential links</h2>
9898 < tbody >
9999 < td class ="block ">
100100 < label >
101- < input
102- id ="checkbox-select-all "
103- type ="checkbox "
104- data-target ="checkbox-select-all.checkboxAll "
105- data-action ="change->checkbox-select-all#toggle "
106- />
101+ < input id ="checkbox-select-all " type ="checkbox " data-target ="checkbox-select-all.checkboxAll " />
107102 < span > Select All / Deselect All</ span >
108103 </ label >
109104 </ td >
Original file line number Diff line number Diff line change @@ -3,18 +3,23 @@ import { Controller } from 'stimulus'
33export default class extends Controller {
44 static targets = [ 'checkboxAll' , 'checkbox' ]
55
6- connect ( ) {
6+ initialize ( ) {
7+ this . toggle = this . toggle . bind ( this )
78 this . refresh = this . refresh . bind ( this )
9+ }
810
11+ connect ( ) {
912 if ( ! this . hasCheckboxAllTarget ) return
1013
14+ this . checkboxAllTarget . addEventListener ( 'change' , this . toggle )
1115 this . checkboxTargets . forEach ( checkbox => checkbox . addEventListener ( 'change' , this . refresh ) )
1216 this . refresh ( )
1317 }
1418
1519 disconnect ( ) {
1620 if ( ! this . hasCheckboxAllTarget ) return
1721
22+ this . checkboxAllTarget . removeEventListener ( 'change' , this . toggle )
1823 this . checkboxTargets . forEach ( checkbox => checkbox . removeEventListener ( 'change' , this . refresh ) )
1924 }
2025
You can’t perform that action at this time.
0 commit comments