Casing problem with ajax and dataTables name under 1.10 beta 2

Casing problem with ajax and dataTables name under 1.10 beta 2

AdeDerbyAdeDerby Posts: 3Questions: 0Answers: 0
edited March 2014 in DataTables 1.10
Hi,

I have found a problem with 1.10 beta 2 (only been using this so not sure if it exists under other versions)

First time posting to a forum so not sure if I am doing this right either.

if you use the following code:

[code]
var table = $('#example').dataTable( {
ajax: "data.json"
} );
[/code]

The returned object does has the .ajax part missing. However if you use:

[code]
var table = $('#example').DataTable( {
ajax: "data.json"
} );
[/code]

It does. All the difference is the use of .dataTable or .DataTable

This does not seem to be explained any where in the documentation (though I could have missed it).

I hope this makes sense!

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Its explained a number of times in the documentation: http://next.datatables.net/manual/api#Accessing-the-API

    > It is important to note the difference between $( selector ).DataTable() and $( selector ).dataTable(). The former returns a DataTables API instance, while the latter returns a jQuery object.

    Among others.

    What you are seeing is not an error - it is intentional. Perhaps I got it wrong doing it that way, but I quite liked the elegance of it - the upper case is more 'constructor' like following the general software trend for classes, while the lowercase is jQuery like - and thus it returns a jQuery object.

    Allan
  • AdeDerbyAdeDerby Posts: 3Questions: 0Answers: 0
    I did not see that as I was looking under the Ajax section, so totally missed it.

    It could be worth putting a note on that section as it is easy to miss the letter change.

    Thanks for clearing it up.
  • AdeDerbyAdeDerby Posts: 3Questions: 0Answers: 0
    Also I know how I got mixed up. In the zero configuration example (https://datatables.net/release-datatables/examples/basic_init/zero_config.html) that uses .dataTable, and as I built on this I did not see the change!
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Fair enough. The same applies to any section of the documentation I think - the answer is always not where you want it :-).

    Allan
This discussion has been closed.