Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Tooltip, if element is removed tooltip is left there #2298

Closed
manishtpatel opened this Issue · 8 comments

6 participants

Manish quasipickle Vincent F A T Tim Scott Dhruv Bhatia
Manish

If control on which tooltip is shown is removed then tooltip is left there and it's stuck there forever.

Steps:
Display a tooltip on a link
When hover over link tooltip is shown
Now clicking on that link removes link from the DOM
Tooltip is left there and never going away

quasipickle

The plugin could be modified to have the tooltip be a child element of whatever it's attached to, but then traversing said element might be off (ie: if you're expecting a set number of children).

Having the tooltip hide when the element is removed would be spotty, as browser support for DOM Mutation events isn't top notch, and IE is unique of course.

The simplest solution would be for you to just call $('#element").tooltip('hide'); before removing the element.

Vincent

A solution could be to implement the "destroy" event (with: http://v3.javascriptmvc.com/jquery/dist/jquery.event.destroyed.js for example). Then, attach the destroy event to the tooltiped object and destroy the tooltip when element is destroy.

F A T
Admin

You can display tooltips inside the element using the "inside" option in placement. However, that has a few problems of it's own.

I recommend just destroying it along with the element when you remove it.

F A T fat closed this
Manish

good enough, thanks

Tim Scott

Here's how I'm doing it (CoffeeScript):

target.click -> 
     $(this).tooltip 'hide'
    #remove stuff including the target

'hide' seems to destroy, which makes sense in this context.

Dhruv Bhatia

@timscott I just profiled the hide method using Chrome's heap inspector and it doesn't actually destroy the event (your code will likely have a memory leak). It would be great to have an actual destroy method that would perform all the necessary garbage collection.

Tim Scott

@dhruv-bhatia Okay, so although the tooltip element is removed from the DOM, which is what I verified, the event on the target element remains in memory? Yes it would be nice to have destroy.

Dhruv Bhatia

@timscott Yes, that's what I observed - I managed to fix it by calling $(el).off() to clear all event handlers after I hide a tooltip. fat is looking into a deactivate method, see #3453.

FYI, you may want to inspect your own app's memory usage - http://gent.ilcore.com/2011/08/finding-memory-leaks.html

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.