Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using jquery ui dialog with tooltip causes tooltip display on opening, not hover

Tags:

jquery-ui

I set up the tooltip and dialog like so:

$(document).ready(function() {
    $( "#dialog" ).dialog({ autoOpen: false });
    $( document ).tooltip();

but when i open the dialog later its close tooltip always appears on opening, NOT just on hovering over close as expected. Has anyone else seen this behaviour/knows why it occurs?

like image 904
user2022581 Avatar asked Jun 06 '13 17:06

user2022581


4 Answers

Setting the items option to exclude the dialog's titlebar close widget seems to work well for me in jQueryUI 1.9+

$( document ).tooltip({
  items: '*:not(.ui-dialog-titlebar-close)'
});
like image 73
Cheekysoft Avatar answered Nov 07 '22 01:11

Cheekysoft


Found a solution:

$( "*" ).tooltip();
$('.ui-dialog-titlebar-close').tooltip('disable')

works in place of the above

like image 2
user2022581 Avatar answered Nov 07 '22 02:11

user2022581


Tooltip appears because a button automatically gets focus when a dialog opens (this is a strange behavior). You need to add an attribute "tabindex" to any element in the dialog to avoid this.

For example:

<table tabindex="1">
like image 1
NatalyaKst Avatar answered Nov 07 '22 01:11

NatalyaKst


According to dialog's documentation:

Upon opening a dialog, focus is automatically moved to the first item that matches the following:

  • The first element within the dialog with the autofocus attribute
  • The first :tabbable element within the dialog's content
  • The first :tabbable element within the dialog's buttonpane
  • The dialog's close button
  • The dialog itself

So my solution was to add autofocus to an empty div at the top of the form I was using in my dialog:

<form action="" method="post" accept-charset="utf-8">
  <div class="stealFocus" autofocus></div>
like image 1
h1-the-swan Avatar answered Nov 07 '22 03:11

h1-the-swan