Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Dec 2006
    Posts
    44
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Is there a way we could findout the no. of calls for an event that are fired...

    I've a div which contains loads of data inside a table, I want to do some loading when onscroll of DIV fires.

    This is fine fine but the problem is when user scroll through mousewheel multiple onscroll events are fired so what I want is to first check if multiple events r in the stack remove them from the stack and do the loading stuff only once, here is the code

    Code:
    <script language="javascript">
    function LoadData()
    {
    	//Here I would check that multiple event thing
    	// and after this load the data
    	getCustomersRiskDetail( document.getElementById( "tbleExposure" ), 1 );
    }
    </script>
    
    <DIV id="divExposure" style="BORDER-RIGHT: #9999ff thin ridge; BORDER-TOP: #9999ff thin ridge; OVERFLOW-Y: scroll; BORDER-LEFT: #9999ff thin ridge; WIDTH: 1104px; BORDER-BOTTOM: #9999ff thin ridge; HEIGHT: 544px"
    									align="center" onscroll = "LoadData()">
    </DIV>
    Last edited by uxair; 01-05-2007 at 06:46 AM.

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,010
    Thanks
    203
    Thanked 2,538 Times in 2,516 Posts
    Something simple like this?

    Code:
    <script language="javascript">
    var loadFlag = 0;
    function LoadData()  {
    if (loadFlag !=0) {
    return false;
    }
    	//Here I would check that multiple event thing
    	// and after this load the data
    	getCustomersRiskDetail( document.getElementById( "tbleExposure" ), 1 );
    loadFlag ++;
    }
    </script>
    Last edited by Philip M; 01-05-2007 at 07:34 AM.

  • #3
    New Coder
    Join Date
    Dec 2006
    Posts
    44
    Thanks
    0
    Thanked 0 Times in 0 Posts
    the problem with this technique is that it will only execute for the first time user scrolls.

    what I want to achieve that when user scrolls and multiple onscroll events are fired, LoadData is called only one, and I guess that could be achieved by cancelling all the pending fired events for onscroll

  • #4
    New Coder
    Join Date
    Dec 2006
    Posts
    44
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up

    Well I was unable to find the fired event thing but I achieved what I want to.

    luv u self.interval

    Here is the code


    Code:
    		var loadFlag = 0;
    		var int = self.setInterval( "LoadData( 1 )", 1000 )
    		function LoadData( riRecordsToLoad )
    		{
    			if ( loadFlag != 0 )
    				return false;
    			loadFlag = 1;
    
    			try
    			{
    				if ( getCustomersRiskDetail( document.getElementById( "tbleExposure" ), riRecordsToLoad ) == false )
    					document.getElementById( 'divExposure' ).onscroll = "";
    			}
    			finally
    			{
    				var int = self.setInterval( "LoadFlag()", 1000 )
    			}
    		}
    		function LoadFlag()
    		{
    			loadFlag = 0;
    		}


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •