Skip to content

Commit

Permalink
fix ajax reload
Browse files Browse the repository at this point in the history
  • Loading branch information
yaza-putu committed Mar 5, 2023
1 parent 99ff6ce commit d9410a8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion helper.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 10 additions & 3 deletions helpers.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const versioningCdnUrl = "V2.0.1";
const versioningCdnUrl = "V2.0.2";
const confirmSweetFinishDefault = {
text : "Click the ? button to return to the previous page",
cancelButtonFirst : "Continue",
Expand Down Expand Up @@ -412,7 +412,7 @@ function ajaxGet(url, blockUi = false) {
}

// ajax Delete
function ajaxDel(url, id, table = null, confirmSweetDelete = null) {
function ajaxDel(url, id,reload = false, table = null, confirmSweetDelete = null) {
const title = confirmSweetDelete == null ? confirmSweetDeleteDefault.title : confirmSweetDelete.title;
const body = confirmSweetDelete == null ? confirmSweetDeleteDefault.body : confirmSweetDelete.body;
const buttonLabel = confirmSweetDelete == null ? confirmSweetDeleteDefault.buttonLabel : confirmSweetDelete.buttonLabel;
Expand All @@ -439,6 +439,11 @@ function ajaxDel(url, id, table = null, confirmSweetDelete = null) {
{
reloadTable(table);
}
if (reload == true) {
setTimeout(function (){
location.reload();
}, 1500);
}
}else {
new sweetError(res.message);
}
Expand Down Expand Up @@ -496,7 +501,8 @@ function setParam(url, param, value) {
}

// handel datatables
function datatable(table, url, columns= [], columnDefs = [], responsive = true) {
function datatable(table, url, columns= [], columnDefs = [], callback, responsive = true) {
callback = callback || function() {};
$(table).DataTable({
ordering: true,
serverSide: true,
Expand All @@ -506,6 +512,7 @@ function datatable(table, url, columns= [], columnDefs = [], responsive = true)
oLanguage: {sProcessing: loadingSpiner},
ajax: {
'url': url,
'data' : callback
},
drawCallback: function (settings) {
// bootrap 3 or 4
Expand Down

0 comments on commit d9410a8

Please sign in to comment.