开发者

AJAX (jquery) + Tooltip

开发者 https://www.devze.com 2023-01-22 05:58 出处:网络
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?

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开发者_JAVA百科');

   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!


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消