Skip to content


Calling $obj.tipsy('hide') breaks on non-tipsy-fied obj #17

TrevorBurnham opened this Issue · 4 comments

2 participants


If you have a jQuery object and you call


when $obj hasn't been tipsy-fied yet, you get

Uncaught TypeError: Cannot read property 'hide' of null

You might ask "well, why would you do that?" The answer is that I'm using live: true to make $obj tipsy on an as-needed basis; if you make the $obj.tipsy('hide'); call after someone's hovered over it, you don't get an error.

I've taken to using

if ($'tipsy')) { $obj.tipsy('hide'); }

as a workaround, but this is obviously a hack.


Yep this should be fixed. What's the expected behaviour when there has been no tipsification? Return null? Throw a catchable error? My gut reaction is the latter but that doesn't seem very idiomatic JS. Keen to hear your thoughts.



I'd much prefer a null return to an exception.

Having said that, it wasn't until I peeked at the source code that I realized that the tipsy() function doesn't simply return this, like a typical jQuery function (or rather, it doesn't when an option string is given). What's the reason for this? The examples in the docs never use the return value.

If there isn't a reason, then I think the ideal behavior would be for $obj.tipsy('hide') to always return $obj. That's what jQuery users expect, right? For instance, $obj.hide() will always return $obj even if $obj is already hidden.


This was a deliberate decision, the reasoning was that since the option string form of tipsy() is basically a dumb proxy to the Tipsy object, that it would be unwise to assume (either now or in the future) the proxied method's return value to be insignificant.

However I can see the argument for chainability. If one needs the return value I guess there's nothing to stop them doing var tipsy = $foo.tipsy(true), retVal = tipsy.blahBlah();.

So, agreed, I'll change it to return the jQuery object.


tipsy object proxy method tolerates null object and now returns this. closed by 23994f5

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.