Skip to content

Commit

Permalink
stopped ajax reoad every time a change is made which stops the automa…
Browse files Browse the repository at this point in the history
…ted page rerouting
  • Loading branch information
bishwaspraveen committed Feb 20, 2024
1 parent 82570cb commit d1dcb29
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 additions & 14 deletions sde_indexing_helper/static/js/candidate_url_list.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ function initializeDataTable() {
"selector": 'td:nth-child(5)'
},
'rowId': 'url',
"stateLoadCallback": function (settings) {
var state = JSON.parse(localStorage.getItem('DataTables_candidate_urls_' + window.location.pathname));
if (!state) {
settings.oInit.pageLength = 1;
}
return state;
},
"ajax": {
"url": `/api/candidate-urls/?format=datatables&collection_id=${collection_id}`,
"data": function (d) {
Expand Down Expand Up @@ -382,8 +389,8 @@ function postDocumentTypePatterns(match_pattern, match_pattern_type, document_ty
csrfmiddlewaretoken: csrftoken
},
success: function (data) {
$('#candidate_urls_table').DataTable().ajax.reload();
$('#document_type_patterns_table').DataTable().ajax.reload();
$('#candidate_urls_table').DataTable().ajax.reload(null, false);
$('#document_type_patterns_table').DataTable().ajax.reload(null, false);
},
error: function (xhr, status, error) {
var errorMessage = xhr.responseText;
Expand All @@ -409,8 +416,8 @@ function postExcludePatterns(match_pattern, match_pattern_type = 0) {
csrfmiddlewaretoken: csrftoken
},
success: function (data) {
$('#candidate_urls_table').DataTable().ajax.reload();
$('#exclude_patterns_table').DataTable().ajax.reload();
$('#candidate_urls_table').DataTable().ajax.reload(null, false);
$('#exclude_patterns_table').DataTable().ajax.reload(null, false);
},
error: function (xhr, status, error) {
var errorMessage = xhr.responseText;
Expand All @@ -435,8 +442,8 @@ function postIncludePatterns(match_pattern, match_pattern_type = 0) {
csrfmiddlewaretoken: csrftoken
},
success: function (data) {
$('#candidate_urls_table').DataTable().ajax.reload();
$('#include_patterns_table').DataTable().ajax.reload();
$('#candidate_urls_table').DataTable().ajax.reload(null, false);
$('#include_patterns_table').DataTable().ajax.reload(null, false);
},
error: function (xhr, status, error) {
var errorMessage = xhr.responseText;
Expand All @@ -462,8 +469,8 @@ function postTitlePatterns(match_pattern, title_pattern, match_pattern_type = 1)
csrfmiddlewaretoken: csrftoken
},
success: function (data) {
$('#candidate_urls_table').DataTable().ajax.reload();
$('#title_patterns_table').DataTable().ajax.reload();
$('#candidate_urls_table').DataTable().ajax.reload(null, false);
$('#title_patterns_table').DataTable().ajax.reload(null, false);
},
error: function (xhr, status, error) {
var errorMessage = xhr.responseText;
Expand Down Expand Up @@ -507,11 +514,11 @@ function deletePattern(url, data_type, url_type = null, candidate_urls_count = n
'X-CSRFToken': csrftoken
},
success: function (data) {
$('#candidate_urls_table').DataTable().ajax.reload();
$('#exclude_patterns_table').DataTable().ajax.reload();
$('#include_patterns_table').DataTable().ajax.reload();
$('#title_patterns_table').DataTable().ajax.reload();
$('#document_type_patterns_table').DataTable().ajax.reload();
$('#candidate_urls_table').DataTable().ajax.reload(null, false);
$('#exclude_patterns_table').DataTable().ajax.reload(null, false);
$('#include_patterns_table').DataTable().ajax.reload(null, false);
$('#title_patterns_table').DataTable().ajax.reload(null, false);
$('#document_type_patterns_table').DataTable().ajax.reload(null, false);
}
});
}
Expand Down Expand Up @@ -677,5 +684,5 @@ $('.document_type_form_select').on('click', function (e) {
});

$('#filter-checkbox').on('change', function () {
$('#candidate_urls_table').DataTable().ajax.reload();
$('#candidate_urls_table').DataTable().ajax.reload(null, false);
});

0 comments on commit d1dcb29

Please sign in to comment.