Skip to content

Instantly share code, notes, and snippets.

@jshirley
Created January 24, 2011 17:20
Show Gist options
  • Save jshirley/793558 to your computer and use it in GitHub Desktop.
Save jshirley/793558 to your computer and use it in GitHub Desktop.
A simple YUI3 example to toggle all checkboxes in a given form with the same name. If you create a checkbox with a class="global", any checkbox with the same name will be selected with it.
YUI().use('node', 'event-delegate', function(Y) {
Y.delegate('change',
function (e) {
var node = e.target;
var form = node.ancestor('form');
form.all('input[name=' + node.get('name') + ']').set('checked', node.get('checked'));
},
document.body, 'input[type=checkbox].global'
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment