Created
October 11, 2009 17:39
-
-
Save Kilian/207764 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
//place inside an anonymous function | |
(function ($) { | |
// on document ready code | |
$(function(){ | |
$.namespace.functionName(); | |
$.namespace2.anotherFunctionName(); | |
}); | |
}(jQuery)); |
This file contains hidden or 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
/* 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)); |
This file contains hidden or 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
//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