HighDots Forums  

Re: Javascript - sequence of events

Javascript JavaScript language (comp.lang.javascript)


Discuss Re: Javascript - sequence of events in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Randy Webb
 
Posts: n/a

Default Re: Javascript - sequence of events - 06-04-2006 , 04:06 PM






bboyle18 (AT) gmail (DOT) com said the following on 6/4/2006 3:13 PM:
Quote:
Hi,

I am working with a table sorting script which can be found here
http://www.workingwith.me.uk/article..._table_sorting
This script works very nicely, but when there is a large amount of data
to sort e.g > 200 then there is a slight delay in the table sort. To
cater for this I want to provide some feedback to the user to inform
them that the sort function is processing. My idea is to add a
"sorting...." message to the top right of the page, much the same as
the 'loading' message in gmail.
To do this I am dynamically creating a div element and adding it to the
document.body
I do this as part of the onclick event that triggers the table sort.

My problem is, eventhough I create and append the 'sorting...' element
at the start of the onclick event (before the sorting is done), the
element only gets added after the sorting is complete?

I cant seem to get the 'sorting..' element to be added to the page
while the sorting is in progress. Does javascript execute things in a
sequence that prevents me adding my element to the page?
Interestingly, I can execute a javascript alert and this gets displayed
before the sorting begins.....why would
document.body.appendChild(myDiv) not?
Hopefully someone has come across this before and can help. I've added
my HTML and javascript below.
<FAQENTRY>
Why doesn't the display get updated when doing time intensive calculations?
</FAQENTRY>


It is a very well known about issue where the UA doesn't get updated
visibly until the function executes. The alert causes a delay so the
display gets updated.

The solution? Call a setTimeout to a second function.

function dummyFunction(){
//create the message here
window.setTimeout(realFunction,60)
}

function realFunction(){
//sort the table

//remove the message when sorting is finished.
}

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/


Reply With Quote
  #2  
Old   
Chris Moltisanti
 
Posts: n/a

Default Re: Javascript - sequence of events - 06-04-2006 , 05:48 PM






That worked great thanks. I had to changed the JS around a bit, but the
setTimeout worked perfectly.

Thanks,

Chris


Reply With Quote
  #3  
Old   
Chris Moltisanti
 
Posts: n/a

Default Re: Javascript - sequence of events - 06-04-2006 , 05:50 PM



That worked thanks. I had to change my JS slightly but the setTimeout
worked perfectly.

Thanks,

Chris


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.