2017-06-15 77 views
0

所以,我有一個彈出窗口切換顯示/隱藏完全罰款點擊它的標識符作爲配置文件和notificationalert的圖形。但是當我點擊正文時,它會隱藏起來,但不會在第一次點擊時重新開啓。它在字形圖標上點擊第二次時打開。 我該如何解決這個問題?彈出不會切換點擊身體

$("#profile").on('click',function(e){ 
e.preventDefault(); 
$.get('/userSettings').done(function(resp){ 
     $('#profile').attr('data-title','<b>'+resp.currentuser+'</b>'); 
     if(resp.fName && resp.fName!="" && resp.lName && resp.lName!=""){ 
     $('#profile').attr('data-content','<span class="glyphicon glyphicon-user" aria-hidden="true">'+" ("+resp.fName+" "+resp.lName+")"+'</span><p></p><p><span class="glyphicon glyphicon-cog" aria-hidden="true"></span><a href="/profile">&nbsp;User Settings</a></p><p><span class="glyphicon glyphicon-log-out" aria-hidden="true"></span><a href="https://stackoverflow.com/users/logout">&nbsp;Signout</a></p>'); 
     } 
     else{ 
     $('#profile').attr('data-content','<p><span class="glyphicon glyphicon-cog" aria-hidden="true"></span><a href="/profile">&nbsp;User Settings</a></p><p><span class="glyphicon glyphicon-log-out" aria-hidden="true"></span><a href="https://stackoverflow.com/users/logout">&nbsp;Signout</a></p>'); 

     } 
     $('#profile').popover({html:true}); 
     $('#profile').popover('toggle'); 
     $('#notificationAlert').popover('toggle'); 
     }).fail(function(err){ 
     $('#profile').attr('data-content',"NO Alerts Found"); 
    }); 
    }); 

     $('body').on('click', function (e) { 
    //did not click a popover toggle, or icon in popover toggle, or popover 
    if ($(e.target).data('toggle') !== 'popover' 
     && $(e.target).parents('[data-toggle="popover"]').length === 0 
     && $(e.target).parents('.popover.in').length === 0) { 
     $('[data-toggle="popover"]').popover('toggle'); 
    } 
}); 
+0

創建一個[jsfiddle](https://jsfiddle.net/)您的問題的例子,以便我們可以檢查並糾正它。 –

回答

0

修正了它。這與我的腳本的其他部分有關。我沒有正確地管理用戶和子用戶之間的會話。另外,我並沒有發送res.send({status:"success"});來確認該事件已經事實上要求它再次切換。