Skip to content

Instantly share code, notes, and snippets.

@nicholasruunu
Created November 2, 2011 12:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicholasruunu/1333484 to your computer and use it in GitHub Desktop.
Save nicholasruunu/1333484 to your computer and use it in GitHub Desktop.
jQuery class template
$(function() {
var MyClass = function() {
var $this = $(this);
var $login_form = $('#login_form');
// Constructor (will always run when loaded)
(function() {
// Submit login_form
$login_form.bind({
submit: function() {
$this.publicMethod();
}
});
})();
// Public method - can be called from client code
this.publicMethod = function() {
console.log('public method called!');
};
// Private method - can only be called from within this object
var privateMethod = function() {
console.log('private method called!');
};
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment