Created
November 2, 2011 12:12
-
-
Save nicholasruunu/1333484 to your computer and use it in GitHub Desktop.
jQuery class template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(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