views:

18

answers:

1

I use an tooltip. When I hide the native browser function for the tooltip function, (remote Attr title), after an Ajax update there is no content at all! How can I fix this?

jQuery('.tooltip').each(function(){
   $(this).data('title',$(this).attr('title'));
   $(this).removeAttr('title');

   jQuery(this).hover(function()
   {
      tooltip.show($(this).data('title'));
   },
   function()
   {
      tooltip.hide();
   });
});

This is what I use when I load the page (also when I use the Ajax Request).

EDIT: IT ONLY WON'T WORK INSIDE FANCYBOX POPUP!

+1  A: 

When you do this:

$(this).data('title',$(this).attr('title'));
$(this).removeAttr('title');

You're overwriting what's in the title key in data each time, including after you blanked out the attribute, instead do this:

if(!$.data(this, 'title')) {
  $.data(this, 'title', $(this).attr('title'));
}
$(this).removeAttr('title');

With this version we're checking if data is already populated, if it is then don't overwrite it with the now-empty title attribute.

Nick Craver
Perfect answer!
Kevin