...

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



uxair
01-05-2007, 07:19 AM
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


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

Philip M
01-05-2007, 08:32 AM
Something simple like this?



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

uxair
01-05-2007, 09:10 AM
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

uxair
01-05-2007, 12:17 PM
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



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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum