簡體   English   中英

僅在單擊時打開Jquery-ui工具提示

[英]Open Jquery-ui Tooltip only on click

我有這個代碼

function DrawTipsProgress(postid, ajaxurl) {

    var data = {
        action: 'ajax_action',
        post_id: postid
    }

    jQuery('#dashicon-' + postid).on("click", function () {

        jQuery.post(ajaxurl, data, function(response) {

            jQuery('#dashicon-' + postid).tooltip({

                position: { my: 'center bottom' , at: 'center top-10' },
                tooltipClass: "myclass",
                content: response

            });

            jQuery('#dashicon-' + postid).tooltip('open');

        });

    });

}

在第一次單擊時,它按預期工作。 如果稍后我嘗試再次懸停按鈕而不再單擊工具提示彈出窗口,並且單擊只是執行ajax調用但不打開工具提示。

懸停時會觸發工具提示。 在你的代碼中,它不會被綁定到元素,直到'click'事件發生,所以它不是真正的點擊導致它顯示...它是點擊后的懸停。 我相信你需要做的是使用啟用禁用 這是一個小例子。 http://jsfiddle.net/ecropolis/bh4ctmuj/

<a href="#" title="Anchor description">Anchor text</a>

$('a').tooltip({
    position: { my: 'center bottom' , at: 'center top-10' },
    tooltipClass: "myclass",
    disabled: true,
    close: function( event, ui ) { 
        $(this).tooltip('disable'); 
        /* instead of $(this) you could also use $(event.target) */
    }
});

$('a').on('click', function () {
     $(this).tooltip('enable').tooltip('open');
});

暫無
暫無

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

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