简体   繁体   中英

show a loading image while a table is being built in a part of the html

I have the below snippet of code that basically builds alot of rows in a data table. here is a demo . I am trying to use slepp to simulate a big dataset here.

    //START:: show a loading message on the screen 
    //draw my rows 
    _.each(file, function(row) {
    //sleep(5000)
    t1.addRows(row)
    }); 
    //END:: STOP showing a loading message on the screen 

and I want to be able to display to the user that it is loading.

How do I do this.

I have the below links but I cannot seem to get them to work

https://stackoverflow.com/a/3617657/2392358

https://stackoverflow.com/a/16485533/2392358

I want to use one of these images

I thinking of using one of these .gif files to display while loading.

SOLUTION

Add the following initialization option:

processing: true

Change your code for adding new rows to

$(".dataTables_processing").show();

setTimeout(function(){
    _.each(file, function(row) {
        t1.addRows(row)
    });  

    t1.oTable.draw();

    $(".dataTables_processing").hide();
}, 100);

DEMO

See this jsFiddle for code and demonstration.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM