Onclick event firing twice while using iscroll

744 views Asked by At

I am using nested iscroll4 but the onclick event on

  • firing two times. first added a div just for swipe using iscroll and its li is below:-

         <li>     
               <div class="pullContainer">
                <div class="wraps" id="w1">
                  <div class="scrolls" id="sc1">
                    <div id="pullDown1" class="pullDowns">
                     <span class="pullDownIcon"></span>
                       <span class="pullDownLabel1">Pull down to refresh...</span>
                     </div>
                     <div class="scrollContainer" id="nearBy"></div>
                       <!-- Template  container -->
                     <script id="myTemplate" type="text/x-jquery-tmpl">
                      {{if (data.length > 0)}}
                     <ul class = "forSmooth" id="nearbyList">
                      {{each data}}
                      <li class = "smooth" data-businessId = "${$value.id}" data-distance = "${$value.distance}" data-prev-page ="homePage" onclick = "alert('hi');">
    

    Here the alert is firing two times...So how can i prevent this by firing second time.

  • 1

    There are 1 answers

    3
    IT ppl On

    try this :

    <li class = "smooth" data-businessId = "${$value.id}" data-distance = "${$value.distance}" data-prev-page ="homePage" onclick = "AlertFunction()";">
    
    function AlertFunction(e){
        alert("Hi");
        e.stopPropagation();
    }
    

    Note : Totally untested code