0

I'm trying to get the auto sorting working which is it, it sets on the url when you load the page: blah.com/?sorts[date]=-1 but you then have to refresh the page for it to work, as it does not sort right away on page load.

  $.ajax({
       // Uncomment the following to send cross-domain cookies:
       //xhrFields: {withCredentials: true},
       url: $('#fileupload').fileupload('option', 'url'),
       dataType: 'json',
       context: $('#fileupload')[0]

   }).always(function () {
       $(this).removeClass('fileupload-processing');
   }).done(function (result) {
       $(this).fileupload('option', 'done').call(this, $.Event('done'), {result: result});
       $('.table-striped').dynatable({
           dataset: {
               files: result,
               ajaxData: {
                   sorts: { 'date': -1 }
               }
           }
       });
   });
halfer
  • 19,824
  • 17
  • 99
  • 186
James
  • 1,668
  • 19
  • 50
  • Not clear what you ask, but you can postpone some code with `setTimeout` – Justinas Jan 05 '17 at 14:22
  • Will try, not sure if it is the problem. When you use the sorting it adds to the end of the URL to sort options. When the page loads i want to auto sort an item which is does but you have to refresh the page in order for it to sort as does not seem to on initial page load even though its setting in the url – James Jan 05 '17 at 14:24
  • Check if you do not try sort elements that is not yet on page (usually async problem of programmers) – Justinas Jan 05 '17 at 14:26
  • That was what i was thinking might of been, just having a look. – James Jan 05 '17 at 14:29
  • Cant work it out, any ideas what i would need to change at all? – James Jan 05 '17 at 14:38
  • Err it is not a duplicate, in fact that one you marked as duplicate is not even the same issue! – James Jan 05 '17 at 14:44
  • The thing you need is dynatable.process(); as found here: http://stackoverflow.com/questions/20891127/updating-table-with-dynatable-plugin – mplungjan Jan 05 '17 at 15:01
  • Will take a look now, thanks mate – James Jan 05 '17 at 15:07

0 Answers0