Skip to content

Instantly share code, notes, and snippets.

@natecavanaugh
Created March 20, 2013 20:04
Show Gist options
  • Select an option

  • Save natecavanaugh/5207965 to your computer and use it in GitHub Desktop.

Select an option

Save natecavanaugh/5207965 to your computer and use it in GitHub Desktop.
toggleDisabled
toggleDisabled = function(field, force) {
var container;
if (field.hasClass('aui-field-input') || field) {
container = field.ancestor('.aui-field');
}
else {
container = field;
field = field.children('.aui-field,.aui-button');
}
container.toggleClass('disabled' force);
field.each(
function(item, index, collection) {
item.toggleClass('disabled', force);
item.set('disabled', force !== undefined ? force : !item.get('disabled'));
}
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment