2012-04-10 32 views
0

當用戶單擊「x」關閉qtip2模式時,我試圖用jquery觸發某些內容。Qtip2 Modal,關閉模式時觸發事件

這裏是我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> 

如果您發現「隱藏:函數(事件,API){」行,這項工作很好,當模式之外,用戶點擊將其關閉,但是當用戶點擊「x」關閉模式時,它只會關閉模態。如何在用戶點擊「x」時「做些什麼」?

謝謝。

回答

0

您是否嘗試過綁定關閉按鈕的點擊事件?

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

// < jQuery 1.7 
$("a.ui-tooltip-close").click(function() { ... }); 
0

爲了趕按鈕的關閉事件中,我發現,你需要趕上mousedown事件上.qtip-close而不是click,它不會被觸發。我假設,因爲插件做了一些事情。

相關問題