Trying to get the value of an initialization option but it doesn't seem to be returned by init()
Trying to get the value of an initialization option but it doesn't seem to be returned by init()
I'm trying to write a jasmine test to check that a datatable is being initialized with the correct options.
In my test I create variable to hold the init()
options, but for some reason some of the config options are not being returned form the call to init()
- specifically the orderMulti
option, but it appears to be the case with other options that are set to false
in the configuration object.
I have confirmed that when the call to create the contains the config option, so is there any internal code that could be preventing init()
returning these options?
This question has an accepted answers - jump to answer
Answers
Hi @hugh.law ,
I just tried it here, and as you can see, the
orderMulti
is being displayed. Would you be able to modify that example and see if you can reproduce the problem you're seeing, please?Cheers,
Colin
Hi @colin, thanks for your reply and yes, it was actually being returned correctly, my mistake.
For a bit of context in case someone else finds this answer in the future - I had a series of tests that would each create an instance of a DataTable and the test would check the
init()
options for each instance. However, In my case, I was notdestroy()
ing each instance correctly after each test.DataTables will not create a new instance if a
table
already has DataTables applied to it - so in my case, while the first test saw the expectedinit
options, in the second test, instead of returning the config options I thought I was setting,init()
was returning the options from the first DataTable I had created in the first test.The solution was to ensure that I called the
destroy()
method at the end of each test.