* special 'all' namespace is selected/unselected respectively.
*/
updateCheckboxes: function() {
- // The 'all' namespace is the FIRST in the list.
- var isAllNS = $select.find( 'option' ).first().is( ':selected' );
+ // The option element for the 'all' namespace has an empty value
+ var isAllNS = ('' === $select.find('option:selected').val() );
// Iterates over checkboxes and propagate the selected option
$.each( checkboxes, function( i, id ) {
- $( '#' + id ).attr( 'disabled', isAllNS );
+ $( '#' + id ).prop( 'disabled', isAllNS );
});
},
init: function() {
- // Populate & bind
- $select = $( '#namespace' ).change( rc.updateCheckboxes );
+ // Populate
+ $select = $( '#namespace' );
- // Trigger once set the initial statuses of the checkboxes.
- $select.change();
+ // Bind to change event, and trigger once to set the initial state of the checkboxes.
+ $select.change( rc.updateCheckboxes ).change();
}
};