Skip to content

Commit b901630

Browse files
authored
Change bookmarkCounter to find multiple selectors (#3351)
This commit will change the bookmarkCounter function to look for multiple selectors instead of one. This way if we want to put the bookmark counter elsewhere it will also be dynamic. Ref: - #3350
1 parent aaa98f7 commit b901630

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

app/javascript/blacklight/checkbox_submit.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ export default class CheckboxSubmit {
3737
this.labelTarget.removeAttribute('disabled')
3838
this.checkboxTarget.removeAttribute('disabled')
3939
this.updateStateFor(!this.checked)
40-
if (this.bookmarkCounter()) this.bookmarkCounter().innerHTML = json.bookmarks.count
40+
this.bookmarksCounter().forEach(counter => {
41+
counter.innerHTML = json.bookmarks.count;
42+
});
4143
}).catch((error) => {
4244
this.handleError(error)
4345
})
@@ -63,8 +65,8 @@ export default class CheckboxSubmit {
6365
return this.form.querySelector('[data-checkboxsubmit-target="span"]')
6466
}
6567

66-
bookmarkCounter() {
67-
return document.querySelector('[data-role="bookmark-counter"]')
68+
bookmarksCounter() {
69+
return document.querySelectorAll('[data-role="bookmark-counter"]')
6870
}
6971

7072
handleError() {

0 commit comments

Comments
 (0)