Ben said:
I didn't know that would happen. But something like this might fix it:
var isSorting = false;
function sortCol(col)
{
...
isSorting = false;
}
function clickHandler(event)
{
if (isSorting) return;
isSorting = true;
...
setTimeout(function() {sortCol(col);}, 1);
}
If that doesn't work, you could do something like this:
var sorting = [0, 0];
function clickHandler(event)
{
if (event.timeStamp > sorting[0] && event.timeStamp < sorting[1])
return;
sorting[0] = event.timeStamp;
// sort the column here...
sorting[1] = Date.getTime();
}
The solution with 'setTimeout' doesn't work in my case because the
browser doesn't react to any click while the sort function is running
(even if I use 'setTimeout' for the sort function).
However the solution with the time stamp is quite good. Many thanks!
At the end of the sort function I do
sort_end_time = new Date().getTime();
and at the beginning of the sort function I check how much time has
passed after the sort function finished last time
if ((new Date().getTime() - sort_end_time) > 300) {
In this example you have to wait 300 milliseconds before you can sort
the next column. Therefore if you click on a column before the running
sort function has finished doing its job the value of '(new Date
().getTime() - sort_end_time)' is less than 300 milliseconds and the
clicked column will not get sorted.
The problem I have now is that when the last javascript command
'sort_end_time = new Date().getTime();' is executed the browser needs
some time to redraw (refresh) the table on the screen. If the table
has only a couple of rows then it takes only some milliseconds but if
the table has e.g. 2000 rows it takes in IE more than 1000
milliseconds.
Therefore the result of '(new Date().getTime() - sort_end_time)' is
always greater than 300 milliseconds.
Is there any possibility, any event where I can execute the command
'sort_end_time = new Date().getTime();' just after the browser is
ready again (after the refresh)? In my case the command 'sort_end_time
= new Date().getTime();' is executed before the browser starts the
redraw (refresh).
Stefan