AWS_Developer
AWS_Developer

Reputation: 856

How to disable Pop Up in javascript

I am new to Javascript. My req is to not show the pop up if i get list from server side as empty list. Before this requirement i was doing something like below code where as soon as user hits the URL, the popup comes as i have used window.onload . Now the requirement got changed and i need to show pop up only when there is some data from backend. Please help me on this.

<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>

I am doing this code in .ascx

Upvotes: 0

Views: 1397

Answers (1)

Ivan Han&#225;k
Ivan Han&#225;k

Reputation: 2306

A piece of code you have put inside function of the onload event of the window you are going to put inside ajax success callback (i guess you are requesting data with 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
    }
});

Upvotes: 1

Related Questions