Problem with Reload callback

Problem with Reload callback

tcardinaltcardinal Posts: 31Questions: 9Answers: 0
edited January 10 in General

I have a method which uploads data to the server using Ajax and returns a json object on success that says whether to reload the table or not. The object returned is:

{"reload": true, "afterReload": "updateOnReload"}

The afterReload value can be any function name with the right signature.

The important part of the method is

table = $("mytable").DataTable();

//repsonse is the parsed json

if (response.reload) {
   table.ajax.reload(function(json){eval(response.afterReload(table)});
};

this works as expected and the function called is as follows

function updateOnReload(table) {

 if (!table.rows().count()){
    table.button("big_step:name").disable();
    table.button("filter_step:name").disable();
 }
 else {
    table.button("big_step:name").enable();
    table.button("filter_step:name").enable();
 };
};

The issue I am having is that table.rows().count() is not returning the correct count - it seems to call the row count prior to loading the data, rather than after.

any ideas?

Answers

  • tcardinaltcardinal Posts: 31Questions: 9Answers: 0

    I update the callBack function to take the json and this is the json prior to the reload.

  • colincolin Posts: 9,558Questions: 0Answers: 1,582

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • tcardinaltcardinal Posts: 31Questions: 9Answers: 0

    I'll set it up and send you login details. probably Mondy

  • tcardinaltcardinal Posts: 31Questions: 9Answers: 0

    strange this one. It is all fine on the test server, just seems to be an issue on my dev machine. I'll leave this open for a bit, just in case it raises it's head on the test box.

Sign In or Register to comment.