2014-10-05 60 views
0

我是JavaScript新手。我的要求是不显示弹出式,如果我从服务器端列表作为空列表。在此要求之前,我正在做类似下面的代码,只要用户点击URL,弹出窗口就会像我使用的window.onload一样。现在需求发生了变化,只有当后端有数据时才需要显示弹出窗口。请帮助我。如何在javascript中禁用弹出式菜单

<script> 
    window.onload = function() { 
     $('#homePopup').bPopup({ 
      easing: 'easeOutBack', //uses jQuery easing plugin 
      speed: 550, 
      transition: 'slideDown' 
     }) 
    } 
</script> 

<div id="homePopup"><span class="buttonCloseModal b-close"><span>X</span></span> 
    <h1>Notifications</h1> 

<div class="ListContainerScroll"> 
     <div> 
       <asp:Repeater ID="rptrNotification" runat="server" OnItemDataBound="rptrNotification_ItemDataBound"> 
         <ItemTemplate> 
           <div> 
            <asp:Literal ID="litNotificationTitle" runat="server" Text='<%# Bind("Title") %>'></asp:Literal> 
           </div> 
           <div> 
            <asp:Literal ID="litNotificationDesc" runat="server" Text='<%# ((SPListItem)Container.DataItem)["NotificationDescription"] %>'></asp:Literal> 
           </div> 
         </ItemTemplate> 
       </asp:Repeater> 
        <div class="noDataAvailable" runat="server" id="divNoDataAvailable" visible="false"></div> 
     </div> 
    </div> 
</div> 

我在做的.ascx

回答

1

一段代码,这个代码,你已经把里面的onload事件中,你要提出阿贾克斯成功回调里面的窗口(我想你的功能在请求数据与jQuery ajax)

$.ajax({ 
    url: 'http://myawesomeurl.net', 
    success: function (ajaxResponse) { 
     //your code start 
     $('#homePopup').bPopup({ 
       easing: 'easeOutBack', //uses jQuery easing plugin 
       speed: 550, 
       transition: 'slideDown' 
      }) 
     ); 
     //your code end 
    } 
});