Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Select All #60

Open
Murphy1976 opened this issue Sep 24, 2018 · 1 comment
Open

Select All #60

Murphy1976 opened this issue Sep 24, 2018 · 1 comment

Comments

@Murphy1976
Copy link

I really like these pretty checkbox/radio buttons.
I am wondering if I were to have multiple checkboxes with the proper markup, what would an external button need to look for to toggle a Select All function?

For example:
HTML

<div class="container">
     <div class="pretty p-curve p-smooth p-bigger">
          <input type="checkbox" name="updateFlags['${status.count}']" value="true">
          <div class="state p-success">
               <label>Checkbox A</label>
          </div>
     </div>

     <div class="pretty p-curve p-smooth p-bigger">
          <input type="checkbox" name="updateFlags['${status.count}']" value="true">
          <div class="state p-success">
               <label>Checkbox B</label>
          </div>
     </div>

     <div class="pretty p-curve p-smooth p-bigger">
          <input type="checkbox" name="updateFlags['${status.count}']" value="true">
          <div class="state p-success">
               <label>Checkbox C</label>
          </div>
     </div>

     <div class="pretty p-curve p-smooth p-bigger">
          <input type="checkbox" name="updateFlags['${status.count}']" value="true">
          <div class="state p-success">
               <label>Checkbox D</label>
          </div>
     </div>
</div>
<button type="button" id="selectAll">Select All</button>

JS:

$("#selectAll").on('click', function(){
     $(".container input[type='checkbox']").prop('checked', $(this).prop('checked'));
});

Clicking the button does nothing in this instance.

@hamed-ehtesham
Copy link

Hi @Murphy1976,
you are using checked property of a button instead of a checkbox (your JS code implies that selectAll must be a checkbox not a button)
this Codepen is what your code must change to

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants