I am currently working on a project that involves using javascript with jquery and bootstrap. My main objective is to have a visually appealing progress bar displayed during heavy javascript computation. Despite knowing the exact progress state of the computation, I am facing an issue where CSS is not updating dynamically during the calculation process.
Although WebWorker is an option for some, it does not fit my specific requirements as I need to interact with a model in the main thread that cannot be easily copied or cloned to a worker.
For instance, currently the progress bar is only updated at the end of the computation. However, my goal is to have it update continuously throughout the process.
Here is a snippet of the HTML code:
<div class="progress">
<div id="loading" class="bar progress-bar progress-bar-info" style="width: 0%"></div>
</div>
And here is the corresponding javascript code:
for (var i = 0; i <= 10; i++) {
$('#loading').css('width', i * 10 + '%');
heavycomputation();
};