Call an "initComplete": function()
Call an "initComplete": function()
chessGuru64
Posts: 79Questions: 18Answers: 1
When someone adds or deletes from their cart https://datatables-ecommerence.000webhostapp.com/ I need to refresh the new item count. What is the easiest way to call the initComplete function?
"initComplete": function(settings, json){
var info = this.api().page.info();
$(".shoppingbasket").append("<div class='basketitems'>" + info.recordsTotal + "</div>");
}
Howcome one cannot type it as a regular function count (settings, json){
I could do it the AJAX way something like: $("#cart").load('https://datatables-ecommerence.000webhostapp.com/' + "#cartCount");
if that is more simple.
This discussion has been closed.
Answers
I accidentally figured out the solution by guessing:
I changed initFunction to:
drawCallback: function () {
My original question theoretically still stands though, is there an easy way to call an initFunction?
The
initComplete
is executed once after the Datatables has initialized. There is not a way to call the function directly. However the initComplete function can call a function you define which is available to use in other areas of your code.Kevin