Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery UI checkbox button select all problem

I am using this to check all checkboxes.

<input type="checkbox" id="all" onclick="$('input[name*=\'selected\']').attr('checked', checked);" />

as long as I use the normal checkboxes everything works fine. When I convert all to jQuery UI checkboxes: http://jqueryui.com/demos/button/#checkbox They get checked -- but not in a visually -- the colors are not changing. I saw that when a jQuery UI checkbox is checked it gets this attribute aria-pressed="true"

Can someone help me understand how can I get this done!

like image 469
ciprian Avatar asked May 04 '26 11:05

ciprian


2 Answers

$('input[name*=\'selected\']').attr('checked', true).button("refresh");

Very easily you will:

  1. Set the underlying radio input
  2. Reflect the state on the JQuery UI Button façade
like image 92
Filippo Vitale Avatar answered May 07 '26 05:05

Filippo Vitale


There a refresh method to update the visual style after you change the checked value programmatically, like this:

$('input[name*=\'selected\']').attr('checked', checked).button("refresh")
like image 20
Nick Craver Avatar answered May 07 '26 05:05

Nick Craver



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!