[jQuery] Re: Safest way to test is a variable is a jQuery object?

2009-08-24 Thread KeeganWatkins
have you considered just checking for a jQuery method? seems like that would be the cleanest, least intrusive way of doing your check, for example: function get_object_from_id(variable) { // if the param has a "attr" property (which jQuery objects do, // b

[jQuery] Re: Safest way to test is a variable is a jQuery object?

2009-08-23 Thread RyanZec
Well I think I am going to be going with a function as that was my first instinct. I see where your going with what you have however that would cause some issue if say an int or JSON object is passed as it is going to return that instead of an expected jQuery object. The code I end up having is:

[jQuery] Re: Safest way to test is a variable is a jQuery object?

2009-08-23 Thread Michael Geary
If all you need to do is distinguish a string from a jQuery object, and you want to insure that future revisions of jQuery will never break your code, I would just test for the string. I'd also put the logic in a function even if you only use it in one place, e.g. // Return a jQuery object g