Fix in ajax list
This commit is contained in:
parent
263dda4721
commit
dca8728315
1 changed files with 28 additions and 6 deletions
34
ajax_list.js
34
ajax_list.js
|
|
@ -250,6 +250,8 @@ $=jQuery;
|
|||
|
||||
search_fields=[];
|
||||
|
||||
activate=0;
|
||||
|
||||
//order ASC=0, DESC=1
|
||||
|
||||
order=0;
|
||||
|
|
@ -342,6 +344,15 @@ $=jQuery;
|
|||
|
||||
this.updateAjaxList=function () {
|
||||
|
||||
//Stop other updateAjaxList if activate.
|
||||
|
||||
if(activate) {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
options=this.options;
|
||||
|
||||
/*if(options.hasOwnProperty("loading")) {
|
||||
|
|
@ -363,14 +374,17 @@ $=jQuery;
|
|||
|
||||
//In url you can send, begin_page, num_elements for pagination.
|
||||
|
||||
|
||||
$.ajax({
|
||||
url: options.url,
|
||||
type: 'GET',
|
||||
data: {num_elements: options.num_elements, begin_page: begin_page, order_field: order_field, order: order, search_all_text: search_all_text},
|
||||
table: this,
|
||||
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();
|
||||
|
||||
|
|
@ -447,12 +461,14 @@ $=jQuery;
|
|||
|
||||
//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) {
|
||||
|
|
@ -461,6 +477,8 @@ $=jQuery;
|
|||
$(this).find('.loading_cells').remove();
|
||||
|
||||
alert('Error: '+data.status+' '+data.statusText);
|
||||
|
||||
activate=0;
|
||||
|
||||
},
|
||||
dataType: 'json'
|
||||
|
|
@ -554,18 +572,22 @@ $=jQuery;
|
|||
|
||||
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();
|
||||
|
||||
e.data.table.updateAjaxList();
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue