11

I have a strange problem with jquery tooltip . I am using the code below

<head>
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script src="http://code.jquery.com/ui/1.11.0/jquery-ui.js"></script>
<script>
  $(function() {
    $(".tooltip").tooltip({ position: { my: "left-30 center+15", at: "right center" } },{ tooltipClass: "custom-tooltip-styling" });
  });
  </script>
</head>
<body>
<a href="link" class="addon_link tooltip" title="test1">test1</a>
<a href="link" class="addon_link tooltip" title="test2">test2</a>
<a href="link" class="addon_link tooltip" title="test3">test3</a>
<a href="link" class="addon_link tooltip" title="test4">test4</a>
</body>
</html>

Tooltip works correctly, but after the show Title adds them to the page, and puts in a div like this

<div role="log" aria-live="assertive" aria-relevant="additions" class="ui-helper-hidden-accessible"><div>test1</div></div>
<div role="log" aria-live="assertive" aria-relevant="additions" class="ui-helper-hidden-accessible"><div>test2</div></div>

My page is in the following form

<head>
    <script src="http://code.jquery.com/jquery-1.10.2.js"></script>
    <script src="http://code.jquery.com/ui/1.11.0/jquery-ui.js"></script>
    <script>
      $(function() {
        $(".tooltip").tooltip({ position: { my: "left-30 center+15", at: "right center" } },{ tooltipClass: "custom-tooltip-styling" });
      });
      </script>
    </head>
    <body>
    <a href="link" class="addon_link tooltip" title="test1">test1</a>
    <a href="link" class="addon_link tooltip" title="test2">test2</a>
    <a href="link" class="addon_link tooltip" title="test3">test3</a>
    <a href="link" class="addon_link tooltip" title="test4">test4</a>
    </body>
    </html>
<div role="log" aria-live="assertive" aria-relevant="additions" class="ui-helper-hidden-accessible"><div>test1</div></div>
    <div role="log" aria-live="assertive" aria-relevant="additions" class="ui-helper-hidden-accessible"><div>test2</div></div>

How can I hide Tooltip after the show?

http://jsfiddle.net/V9R2M/2/

bnnoor
  • 656
  • 2
  • 13
  • 31

8 Answers8

16

No need to edit anything in the source code of js files. You are missing the alternate theme (.css) file for the jQuery Tooltips. Just add cascading style sheet link in the head tag as shown below, & the jQuery tooltip will work smoothly

<!-- jQuery style for Tooltips -->
<link href="https://code.jquery.com/ui/1.11.0/themes/smoothness/jquery-ui.css" rel="stylesheet" type="text/css" />

OR you can append your own style sheet file(.css) with this code

.ui-helper-hidden-accessible {
border: 0;
clip: rect(0 0 0 0);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
}

Hope this helps somwone!... :)

Ravi Tirumale
  • 569
  • 6
  • 7
  • 2
    This didn't help me. :( – sferret Jan 15 '16 at 22:48
  • @sferret : Which jQuery UI version you are using? Hope you added the right CSS file for it. Here you can get the alternate CSS files link for the jQuery-ui.js file https://code.jquery.com/ui/ The latest version of jQuery UI is 1.12.0-beta.1. And If you have added this, then you have to look for CSS file link of latest version 1.12.0-beta.1. – Ravi Tirumale Jan 16 '16 at 20:17
  • 5
    This accepted answer has near nothing to do with the solution to the overindulged accessibility issue of jquery-ui tooltips. I think @lepix answer below is the best option. A tear down method for the tooltip on "close". – RemEmber Feb 12 '16 at 12:56
  • 2
    this will not help avoiding the flooding of your page with those divs, only style them correctly. – Udo Klimaschewski Jul 28 '16 at 14:12
  • Adding the css reference worked perfectly with summernote – m0r6aN Jun 07 '19 at 15:57
11

Simply I have added close method to my initialization and it's working fine.

close: function (event, ui) {
            $(".ui-helper-hidden-accessible").remove();
        } 
Ahmed Mostafa
  • 419
  • 6
  • 16
6

Here's a way to remove these elements again without hacking jquery-ui:

$(elem).tooltip({
...
   /* work around https://bugs.jqueryui.com/ticket/10689 */
   create: function(ev, ui) {
      $(this).data("ui-tooltip").liveRegion.remove();
   }
});
nuddlegg
  • 141
  • 1
  • 4
5

Same problem here, jQuery UI sometimes would add more than 4000 of these elements, switching back to jQuery UI 1.10.1 fixed the problem for me.

David Hirtz
  • 123
  • 8
1

I did find a solution for my problem.

I had to change the style of this element:

.ui-helper-hidden-accessible{
    display: none;
}
NT3RP
  • 15,262
  • 9
  • 61
  • 97
bnnoor
  • 656
  • 2
  • 13
  • 31
1

I just modified the source code:

First search for .ui-helper-hidden-accessible

then remove .appendTo(this.document[0].body)

this will make the element don't append to body but won't affect the code run

then those div will only append into memory

user3896501
  • 2,987
  • 1
  • 22
  • 25
  • 2
    This "fix" **did** affect my code - the tooltips do not get rendered properly. Instead I do this: `$("div.ui-helper-hidden-accessible div:hidden").remove();` within the `open` event on tooltip initialize function. – Andrew Gee Nov 10 '14 at 11:13
  • This fix worked perfectly for me - I had the CSS, so they were correctly hidden, but I was getting hundreds of the divs added to the DOM, most of which were empty (mutiple tabs, containing jQuery big Datatables with lots of tooltips.) – John - Not A Number Jan 10 '18 at 18:37
1

According to this ticket from jQuery UI, this is a feature added in jQuery UI 1.11.0 to improve accessibility : http://bugs.jqueryui.com/ticket/10689

If you want to entirely remove the appended <div> from your code, you have to destroy the tooltip :

$(document).tooltip( "destroy" );

You can also go back to jQuery UI 1.10.x, the tooltip plugin of this version doesn't create supplementary <div> for accessibility purposes.

lepix
  • 4,992
  • 6
  • 40
  • 53
0

add the close event handler to your tooltip initialization. this will auto-remove the useless divs.

$('#attach-id').tooltip({
    close: function () {
        $(".ui-helper-hidden-accessible > *:not(:last)").remove();
    }
});