Skip to content

Instantly share code, notes, and snippets.

@sinefunc
Created August 1, 2010 13:15
Show Gist options
  • Save sinefunc/503344 to your computer and use it in GitHub Desktop.
Save sinefunc/503344 to your computer and use it in GitHub Desktop.
// This is a mixin that will be applied to a `fieldset.row`.
// `this` in these functions will refer to a $("fieldset.row").
// Put your long complicated functions here
var Row = {
$name: function() {
return this.find('input[name=name]');
},
changeName: function(value) {
this.$name().val(value);
},
disable: function() {
this.find('select, input').attr('disabled', 1);
this.find('span').html("(disabled)");
}
};
// Now they can be accessed like so...
$row = $("fieldset.row").extend(Row);
$row.changeName("Jason");
$row.disable();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment