1

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

2
  • Why downvote this without explanation? Commented Jul 10, 2009 at 18:44
  • The tooltip on the down arrow will give you enough explanation, Jimmy. Commented Jul 10, 2009 at 19:34

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

Comments

1

You can also check this very good article about object literal pattern written by rmurphey: http://blog.rebeccamurphey.com/2009/10/15/using-objects-to-organize-your-code

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.