Using XHR event , cannot overwrite data if called from a function
Using XHR event , cannot overwrite data if called from a function
timcadieux
Posts: 76Questions: 22Answers: 0
I want to overwrite the data in my table.. I use the XHR event to call my GetDatatable which returns data but the data in the Datatable never changes. The below example replicates this....the table will be updated with Test A, Test B but never do Test 1, Test 2 show up even though I step through the code and watch json.aaData be filled.
Any ideas would be much appreciated.
$(document).on("xhr.dt", ".wb-tables", function (e, settings, json, xhr) {
page.GetDataTable()
.then(
function passData(data) {
var q = $.Deferred();
//console.log(json);
console.log(data);
var temp = [ // DOES NOT OVERWRITE
{
"title": "Test 1"
},
{
"title": "Test 2"
},
]
json.aaData = temp;
q.resolve();
return q.promise();
});
var temp = [ // DOES OVERWRITE
{
"title": "Test A"
},
{
"title": "Test B"
},
]
json.aaData = temp;
});
},
GetDataTable: function (callback) {
var q = $.Deferred();
data.GetCustomDateRangeData(myQuery, function (data) {
var s = [];
s = js.utils.RemoveDups(data.articles);
q.resolve(s);
});
return q.promise();
}
This discussion has been closed.