I have a button to calculate and make an indicator:
& lt; Button class = "Btn" type = "button" onclick = "$ ('# busy'). Show (); Calculate ();" & Gt; OK & lt; / Button & gt; & Lt; Div id = "busy" style = "display: none;" & Gt; Calculation ... & lt; / Div & gt; In this case what the browser does, calculates (), and then shows the div when the calculation () function first tries to show the div and then calculates.
How do I create events in the intended order?
Edit: Maybe CSS changes before calculation, but it has not been provided until after the calculation. Also tried with click event handling but same thing.
jQuery . Show () display does nothing except making a change in the CSS property (with some magic on previous states). However, everything in the syncronized code is almost impossible that your calculation () method is called here first.
It is more likely that your calculation () method is doing some heavier contemporaneous, blocked interceptions and that the browser connects two code segments together. It happens that the browser, JavaScript code, CSS rendering and normal "UI revision and reflow" are processed in the same Q and so in the same thread. I'm talking about such a " UI line " here In short, you should "sharpen" your calculation () function, double it into smaller sections. The worst option is setTimeout to a SetTimeout and postponed to call calculate () . Later your immediate problem will be solved, but the browser and UI queue will still be blocked later. Example: As I have said earlier, you do not really want to do that, it is an example to make a clear example in any real world scenario. You should go back to the drawing board and think about the calculation () here and how you can divide it into smaller parts. A lot of JavaScript is the convenient way to reduce long-running processes using the run-script script timer , which is basically a UI cue and a browser In many asyncronous loops to breathe in between the code loop uses the sync loop.
No comments:
Post a Comment