diff --git a/ajax_list.js b/ajax_list.js
index 0dd1468..ae7f381 100644
--- a/ajax_list.js
+++ b/ajax_list.js
@@ -40,6 +40,14 @@ $=jQuery;
}
+ if(!$(this).attr('id')) {
+
+ console.log('You need an id for the table');
+
+ return false;
+
+ }
+
exclude_list=[];
if(options.hasOwnProperty("exclude_list")) {
@@ -238,6 +246,8 @@ $=jQuery;
search_all=false;
+ search_all_text='';
+
search_fields=[];
//order ASC=0, DESC=1
@@ -265,11 +275,11 @@ $=jQuery;
}
- list_tr='
\
- | Loading... | \
+ list_tr='
\
+ | Loading... | \
';
- $(this).append(list_tr);
+ /*$(this).append(list_tr);*/
if(!options.hasOwnProperty("num_elements")) {
@@ -346,15 +356,22 @@ $=jQuery;
}
+ $(this).find('tr.row_list').remove();
+
+ $(this).append(list_tr);
+
+
//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},
+ 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('.loading_cells').remove();
+
//$(options.loading).hide();
//console.log(table.options);
@@ -363,8 +380,6 @@ $=jQuery;
var z=0;
- $(this.table).find('tr.row_list').remove();
-
for (const row of data.items) {
//console.log(element);
@@ -415,6 +430,7 @@ $=jQuery;
options.success(data);
}
+
}
else {
@@ -426,11 +442,23 @@ $=jQuery;
}
}
+
+ if(search_all) {
+
+ //Add input event to search when search is done
+
+ var search_input='#'+$(this.table).attr('id')+'_search_in_table';
+
+ $(search_input).on('input', {table: this.table}, update_list_search);
+
+ }
+
},
error: function (data) {
- $(options.loading).hide();
+ //$(options.loading).hide();
+ $(this).find('.loading_cells').remove();
alert('Error: '+data.status+' '+data.statusText);
@@ -518,8 +546,26 @@ $=jQuery;
if(search_all) {
console.log('Search all...')
- //$(this).insertBefore('');
+ $('
').insertBefore($(this));
+ //console.log($(this).attr('id'));
+
+ //$(form).find(".input_performance").on('keyup', function (e) {
+
+ function update_list_search(e) {
+
+ var search_input='#'+$(e.data.table).attr('id')+'_search_in_table';
+
+ $(search_input).off();
+
+ search_all_text=$(this).val();
+
+ e.data.table.updateAjaxList();
+
+ return false;
+ }
+
+ //$('#'+$(this).attr('id')+'_search_in_table').on('input', {table: this}, update_list_search);
}
//First loading of list