DISABLING POP UP IN JAVASCRIPT

Hugh Jackman

Total Post:52

Points:366
Posted by  Hugh Jackman
C#  ASP.Net 
 827  View(s)
Ratings:
Rate this:

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>

 

  1. Norman Reedus

    Post:45

    Points:315
    Re: Disabling Pop Up in javascript

    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

        }

    });

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!