Qtip2模态,关闭模态时触发事件

时间:2012-04-10 22:29:01

标签: jquery modal-dialog qtip2

当用户点击“x”关闭qtip2模式时,我试图用jquery触发一些东西。

这是我的模态的JS:

<script language="javascript" type="text/javascript">
$('.show_likes_modal').live('mouseover', function(event) {//SHOW LIKES MODAL
    clearInterval(auto_refresh); auto_refresh = 0;
    var itemid = $(this).attr("itemid");
    var itemtype = $(this).attr("itemtype");
        $(this).qtip({
        id: 'likesmodal',
        content: {
            text: '<img src="images/loading.gif" alt="Loading..." />',
            ajax: {url: 'modals/show_likes.php',type: 'GET',data: { itemid: itemid,itemtype:itemtype}},
            title: { text: 'People who like this:',button: true}
        },
        position: {my: 'centered',at: 'centered',target: $(window)},
        show: {event: 'click',solo: true,modal: true},
        hide: false,
        style: 'ui-tooltip-light ui-tooltip-rounded',
        events: {
        hide: function(event, api){
         auto_refresh = setInterval(function (){$('#bottom_middle').load(thisurl + '&timer=' + new Date().getTime() + ' #bottom_middle' );}, 5000);             
         $(this).qtip("destroy"); 
        }
       }        
      }); 
return false;     
}); 
</script>

如果您注意到“hide:function(event,api){”行,当用户单击模态外部以关闭它时,此工作正常,但当用户单击“x”关闭模式时,它只是关闭模态。当用户点击“x”时,我怎么能“做某事”?

感谢。

2 个答案:

答案 0 :(得分:1)

为了捕捉按钮的结束事件,我发现您需要在mousedown而不是.qtip-close上捕捉click事件,它不会是触发。我假设因为插件对它做了一些事情。

答案 1 :(得分:0)

您是否尝试过绑定关闭按钮的点击事件?

// > jQuery 1.7
$("a.ui-tooltip-close").on("click", function() { ... });

// < jQuery 1.7
$("a.ui-tooltip-close").click(function() { ... });
相关问题