Search code examples
jqueryoopobject-literal

Using the object literal notation with jQuery


the other day I read this article by Alan Storm called "Using jQuery and the Object Literal Singleton/Module Pattern".

Now I'm wondering if any of you are writing jQuery code using the object literal notation a lot? I'd be happy to check some code examples and/or get advise on when it actually makes sense to use this notation.

Thanks


Solution

  • North...

    I first saw the Object literal pattern in the wild in a joomla extension called jomsocial. At first I was not aware of what i was looking at but it seemed like a slick way to implement code across multiple interfaces. After some searching I discovered its a pattern that is used in the jQuery community and not just something they cooked up.

    Here is a good sample of it in action..

    http://www.jomsocial.com/components/com_community/assets/script-1.2.js