dimanche 1 avril 2018

How to make the label of ransack checkbox filter clickable

I am building a rails app and I use ransack for search and filtering. In one instance, I use ransack as a checkbox filter. The problem is, a user can only click on the checkbox for the filtering to work. What i want is for the user to be able to click the checkbox label as well and the same filter would apply. This is better for user experience since it may be daunting to always have to click inside of the checkbox. This is the view code for the ransack checkbox filter

  <% new_roles.uniq.each do |new_role| %>
    <div class="styled-input-container">
      <%= check_box_tag('q[role_eq_any][]', new_role) %>
      <%= new_role %>
    </div>
  <% end %>

Aucun commentaire:

Enregistrer un commentaire