Skip to content

Commit

Permalink
Add the checked filters count in the browse page
Browse files Browse the repository at this point in the history
  • Loading branch information
Bilelkihal authored and syphax-bouazzouni committed Apr 19, 2023
1 parent 719e456 commit 75705a6
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions app/javascript/controllers/show_filter_count_controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Controller } from "@hotwired/stimulus"

// Connects to data-controller="show-filter-count"

export default class extends Controller {
static targets = ["countSpan"]
updateCount(){
const checkInputs = this.element.querySelectorAll('input:checked')
const count = checkInputs.length
this.countSpanTarget.style.display = count === 0 ? "none" : "inline-block"
this.countSpanTarget.innerHTML = count === 0 ? "" : count
}
}

0 comments on commit 75705a6

Please sign in to comment.