wnas

Different var, same subject

habari

I recently tried to do something and I don't know if it is all that good. If somebody has an opinion about it, I would love to hear it.

I have been using the $ suffix for variables that are really jQuery objects. But I keep coming across occurrences that need the real variable, aka not the jQuery one.

So what I tend to do now is something like:


collection : {
	$foo	: $('.bar'),
	foo		: '.bar'
}

In this way I can use both the jQuery object easily and the normal variable, like this:


// use the jQuery object
collection.$foo.action()

// use the normal object
$('body').find(collection.foo)

What do you think, is this too much or do you use this too?

I am trying to get a better last example, 'cause this ain't all that clear I think...

← Home