I little while ago I had a situation where I thought it would be
useful to bind jQuery events to custom JavaScript objects. I didn't
think it should work, as I thought you could only select DOM nodes.
But as you probably know - that's not true. You can select objects too
(boring details here... 
http://www.mrspeaker.net/2009/10/28/using-jquery-on-javascript-objects/).

The bit of jQuery code that let's you do this seems to be in the init
function where objects fall through to the final path of selector
code: return this.setArray(jQuery.isArray( selector ) ? selector :
jQuery.makeArray(selector));

So it puts the object in an array and you can call some jQuery
functions on it: like bind and data and even include the selections in
plugin code. The data stores in the cache object and so seems like a
good way to store arbitrary data if you don't want to store it in the
object itself (for example 3rd party map applications give you
JavaScript objects for markers, but you can't rely on the map provider
not to change names and you overwrite properties etc)

My question is: is this functionality intentional, and can I rely on
it - or is it just "accidental" that objects get caught this way?

Thanks!

--

You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to jquery-...@googlegroups.com.
To unsubscribe from this group, send email to 
jquery-dev+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en.


Reply via email to