Newby Question concerning jquery code for options

Newby Question concerning jquery code for options

tim1955tim1955 Posts: 5Questions: 2Answers: 0

Thanks to all who created, maintain and provide assistance for DataTables. It is a wonderful program and I was able to get it working. After several hours though I still cannot understand how to code options. I am new to Java Script and jQuery and I think that is the problem. I initialized DataTables with jQuery and it works fine. I used the following code:

$(document).ready( function () { $('#mytable').DataTable(); } );

Where I am getting confused is in setting options like paging. The sample code given in DataTables is:

$('#example').DataTable( {
paging: false
} );

I think I should bracket the code with tags?
Replace the #example with the name of my table which is #mytable ?
And then place it in my HTML header next to the initializing code?
Or should I try to incorporate the code into the initialization code?

I tried all but nothing seems to work.

Any assistance is appreciated.

Thanks again for a wonderful program.

Best Regards,
Tim

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 20,359Questions: 26Answers: 4,777
    edited April 11 Answer ✓

    The examples don't show how to layout a web page. It is assumed that the developer has this basic knowledge.

    I think I should bracket the code with tags?

    Yes. Maybe this tutorial will help.

    Replace the #example with the name of my table which is #mytable ?

    Replace #example with a selector, usually the table id, that finds one or more table elements that are to be Datatables.

    See this simple example with your code snippet, look in the HTML tab at the bottom for the Javascript.
    https://live.datatables.net/noqezabu/1/edit

    Kevin

  • tim1955tim1955 Posts: 5Questions: 2Answers: 0

    Thank you very much for your informative and helpful answer. The tutorial was especially helpful to understanding why the script needs to be placed at the end of the HTML file. Your example was very helpful too. Thanks again!
    Tim

Sign In or Register to comment.