Note that there are some explanatory texts on larger screens.

plurals
  1. POjavascript client-side-only loading notification
    primarykey
    data
    text
    <p>I am sorting a table (client-side) using jQuery. The table is variable length, and when the dataset is large, the sort can take around 3-5 seconds. I would like to show a div (id="sorting") with a spinner or "Please Wait" notification while javascript sorts my table. However, the notification isn't working as expected. Here is the gist of my code:</p> <pre><code>var sortableList; var sortField; var sortDir; $(document).ready(function(){ $('body').delegate('.sortable-heading','click',function(){ sortData($(this)); }); }); function sortData(obj){ $('#sorting').show(); sortableList = []; $('.data-row').each(function(){ var rowData = {}; var sortKey = obj.attr('id'); var i = obj.index(); var val = $(this).find('td:eq(' + i + ') .val-text').text(); if(sortKey == 'adjHeading'){ val = $.trim(val); }else{ val = $.trim(val) ? parseInt(val) : 0; } rowData[sortKey] = val; rowData.rowHtml = $(this).clone().wrap('&lt;p /&gt;').parent().html(); sortableList.push(rowData); }); redrawTable(obj); } function redrawTable(obj){ if(obj.attr('id') == sortField){ sortDir = sortDir == true ? false : true; } sortField = obj.attr('id'); var primer = sortField == 'adjHeading' ? function(a){return a.toUpperCase()} : parseInt; sortableList.sort(sort_by(sortField,sortDir,primer)); $('#pivot-table-1').html(topRowHeading1 + topRowHeading2); for(var i in sortableList){ $('#pivot-table-1').append(sortableList[i].rowHtml); } $('#sorting').hide(); } </code></pre> <p>When the click function fires, the table gets sorted, and I never see my loading div. If I comment out the $('#sorting').hide() call, the div gets displayed only AFTER the table gets sorted. I though javascript was supposed to execute from top-to-bottom. Any idea why it is not in this case?</p> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload