Fix in ajax list

This commit is contained in:
absurdo 2024-01-21 13:13:31 +01:00
parent 263dda4721
commit dca8728315

View file

@ -250,6 +250,8 @@ $=jQuery;
search_fields=[]; search_fields=[];
activate=0;
//order ASC=0, DESC=1 //order ASC=0, DESC=1
order=0; order=0;
@ -342,6 +344,15 @@ $=jQuery;
this.updateAjaxList=function () { this.updateAjaxList=function () {
//Stop other updateAjaxList if activate.
if(activate) {
return false;
}
options=this.options; options=this.options;
/*if(options.hasOwnProperty("loading")) { /*if(options.hasOwnProperty("loading")) {
@ -363,14 +374,17 @@ $=jQuery;
//In url you can send, begin_page, num_elements for pagination. //In url you can send, begin_page, num_elements for pagination.
$.ajax({ $.ajax({
url: options.url, url: options.url,
type: 'GET', type: 'GET',
data: {num_elements: options.num_elements, begin_page: begin_page, order_field: order_field, order: order, search_all_text: search_all_text}, data: {num_elements: options.num_elements, begin_page: begin_page, order_field: order_field, order: order, search_all_text: search_all_text},
table: this, table: this,
success: function (data) { success: function (data) {
$(this.table).find('tr.row_list').remove();
$(this.table).find('.loading_cells').remove(); //$(this.table).find('.loading_cells').remove();
//$(options.loading).hide(); //$(options.loading).hide();
@ -447,12 +461,14 @@ $=jQuery;
//Add input event to search when search is done //Add input event to search when search is done
var search_input='#'+$(this.table).attr('id')+'_search_in_table'; //var search_input='#'+$(this.table).attr('id')+'_search_in_table';
$(search_input).on('input', {table: this.table}, update_list_search); //$(search_input).on('input', {table: this.table}, update_list_search);
} }
activate=0;
}, },
error: function (data) { error: function (data) {
@ -461,6 +477,8 @@ $=jQuery;
$(this).find('.loading_cells').remove(); $(this).find('.loading_cells').remove();
alert('Error: '+data.status+' '+data.statusText); alert('Error: '+data.status+' '+data.statusText);
activate=0;
}, },
dataType: 'json' dataType: 'json'
@ -554,18 +572,22 @@ $=jQuery;
function update_list_search(e) { function update_list_search(e) {
var search_input='#'+$(e.data.table).attr('id')+'_search_in_table'; //e.stopPropagation();
$(search_input).off(); //var search_input='#'+$(e.data.table).attr('id')+'_search_in_table';
//$(search_input).off();
search_all_text=$(this).val(); search_all_text=$(this).val();
e.data.table.updateAjaxList(); e.data.table.updateAjaxList();
e.preventDefault();
return false; return false;
} }
//$('#'+$(this).attr('id')+'_search_in_table').on('input', {table: this}, update_list_search); $('#'+$(this).attr('id')+'_search_in_table').on('input', {table: this}, update_list_search);
} }
//First loading of list //First loading of list