0

I have a table that's being generated with PHP

<table id="mytable" class="tablesorter tablesorter-jui ui-widget ui-widget-content ui-corner-all hasStickyHeaders">
<thead style="">//code for headers </thead>
<tbody>
<?php 
foreach ($active_participants as $participant) 
{
//code for rows..
}
?>
</tbody>
</table>

I am applying the jquery tablesorter plugin to it, however it does not sort(no jquery errors). I need it to display on page load, because it's the first thing the user will see, however can I have it wait for the page to finish loading before applying

 $("#myTable").tablesorter({ sortList: [[0,0], [1,0]] });

what is the proper way to do this?

2 Answers 2

2

You would want to do this in the documents ready function. So in the head section of your html just add:

<script type="text/javascript">
$(document).ready(function() {
    $("#myTable").tablesorter({ sortList: [[0,0], [1,0]] });
});
</script>

That will run once the document is fully loaded.

EDIT: Reyaner Beat me to the answer. :)

Sign up to request clarification or add additional context in comments.

Comments

0

did you try this:

$(document).ready(function(){
    $("#myTable").tablesorter({ sortList: [[0,0], [1,0]] });
});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.