簡體   English   中英

關於ajax問題的jquerytools工具提示

[英]jquerytools tooltip on ajax issue

好吧我每15秒做一次ajax調用,這是第一次在ajax調用時“禁用”工具提示,我修復了這個運行函數再次調用啟動工具提示的函數。

問題是..如果在進行ajax調用時有一個工具提示“打開”,這個只有這個項目的工具提示會被永久銷毀,其余的工作正常。 當ajax運行時,再次打開工具提示。

我怎樣才能解決這個問題..

這是我的代碼

  function notifications() {
        $.ajax(
                {
                    type: "POST",
                    //data: dataparam,
                    url: "<?php echo $notifurl;?>",
                    success: function(msg)
                        {
                            if(msg !="")
                            {
                                $("#ajaxnotif").empty().html(msg);
                                $('.tooltip').remove();
                                 ttp();
                                //$("#suggestDiv").show();
                            }
                            else
                            {
                                $("#ajaxnotif").empty().html(msg); 
                                $('.tooltip').remove();
                                ttp();
                                //$("#suggestDiv").hide();
                            }
                        }
                });
        }


$(document).ready(notifications);
window.setInterval(function(){
  notifications();
}, 15000);

var $tooltip = null;
    var $tooltip2 = null;
var $tooltip3 = null;
    function ttp() {

    $tooltip = $('.marcleidnot[title]').tooltip({
    delay:0,
    slideInSpeed: 300,
    slideOutSpeed: 200,
    bounce: false,
    /*bounce: false*/
    relative: false, // <-- Adding this should sort you out
    slideOffset: 5,
   /* effect: 'slide',
    direction: 'down',
    slideInSpeed: 300,
    slideOutSpeed: 200,*/
    position: 'top center'
});


$tooltip2 = $('.fav[title]').tooltip({  
    delay:100,
    slideInSpeed: 300,
    slideOutSpeed: 300,
    /*bounce: false,*/
    relative: false, // <-- Adding this should sort you out
   effect: 'slide',
    direction: 'down',
    /*slideInSpeed: 300,
    slideOutSpeed: 200,*/
    position: 'top center',
    offset: [10, -2]
});

 $tooltip3 = $('.nofav[title]').tooltip({
    delay:100,
    slideInSpeed: 300,
    slideOutSpeed: 300,
    /*bounce: true,*/
    relative: false, // <-- Adding this should sort you out
    effect: 'slide',
    direction: 'down',
    /*slideInSpeed: 300,
    slideOutSpeed: 200,*/
    position: 'top center',
    offset: [10, -2]
});

    }


$('body').click(function() {
  $('.tooltip').remove();//remove the tool tip element
});

我認為你沒有正確使用tooltip api。 而不是

$('.tooltip').remove();

$tooltip.tooltip("destroy");
$tooltip2.tooltip("destroy");
$tooltip3.tooltip("destroy");

感謝user3352495,我弄清楚問題是什么,然后我弄清楚了

$tooltip = $('.marcleidnot[title]').tooltip("destroy");
$tooltip2 = $('.fav[title]').tooltip("destroy");
$tooltip3 = $('.nofav[title]').tooltip("destroy");

到目前為止工作正常

實際上我發現我只需要刪除它!

只是重新啟動功能

TTP(); 在ajax解決這個問題:D

問題是Jquery Tools中的工具提示默認情況下不會創建.tooptip元素,而只會在工具提示第一次出現時創建它們。 所以在你的情況下,當$tooltip出現時,只有一個.tooltip元素與之關聯,另外2個尚未出現。

要全面刪除所有工具提示,您可以使用此插件 它會刪除.tooltip元素(如果它已經存在)或者取消綁定鼠標事件(如果不存在)。 添加插件后,您只需調用$tooltip.tooltip('remove')

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM