north
north

Reputation: 605

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

Upvotes: 1

Views: 2769

Answers (2)

sparrovv
sparrovv

Reputation: 7824

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

Upvotes: 1

JBeckton
JBeckton

Reputation: 7111

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

Upvotes: 1

Related Questions