Skip to content

Instantly share code, notes, and snippets.

@Kilian

Kilian/base.js

Created Oct 11, 2009
Embed
What would you like to do?
//place inside an anonymous function
(function ($) {
// on document ready code
$(function(){
$.namespace.functionName();
$.namespace2.anotherFunctionName();
});
}(jQuery));
/* a small pattern to make jQuery functionality maintainable and readable*/
//place inside an anonymous function
(function ($) {
//request namespace or make a new object
$.namespace = $.namespace || {};
//add (new) functions to your namespace
$.extend($.namespace, {
functionName: function() {
//your code...
},
anotherFunctionName: function() {
//your code...
},
});
}(jQuery));
//place inside an anonymous function
(function ($) {
//request namespace or make a new object
$.namespace2 = $.namespace2 || {};
//add (new) functions to your namespace
$.extend($.namespace2, {
functionName: function() {
//your code...
},
anotherFunctionName: function() {
//your code...
},
});
}(jQuery));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.