MyUSJ.tableLiveFilter.init({
searchInput: $('#search_filter'),
searchTable: $('#ad_programs_sections, #ad_language_sections, #ad_other_sections')
});
Created
October 29, 2012 07:34
-
-
Save godbout/3972151 to your computer and use it in GitHub Desktop.
Quick live filtering for tables (under MyUSJ scope, not jQuery)
$((function () {
'use strict';
MyUSJ.tableLiveFilter = {
init: function (config) {
this.config = config;
this.bindEvents();
},
bindEvents: function () {
this.config.searchInput.on('keyup search', this.filter);
},
filter: function () {
var self = MyUSJ.tableLiveFilter,
$this = $(this),
searchTableTr = self.config.searchTable.find('tbody>tr');
if ($this.val() !== '') {
searchTableTr.hide();
self.config.searchTable.find('td:contains-ci(\'' + $this.val() + '\')').parent('tr').show();
} else {
searchTableTr.show();
}
}
};
}()));
$.extend($.expr[':'], {
'contains-ci': function (elem, i, match, array) {
'use strict';
return (elem.textContent || elem.innerText || $(elem).text() || '').toLowerCase().indexOf((match[3] || '').toLowerCase()) >= 0;
}
});
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment