Update filter on return plugin

**Fixes legacy API method `fnFilterOnReturn`** #354
pull/470/head
Brian Matovu 5 years ago committed by GitHub
parent 3f380dc9f9
commit 85e626920f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,36 @@
/**
* This plug-in removes the default behaviour of DataTables to filter on each
* keypress, and replaces with it the requirement to press the enter key to
* perform the filter.
*
* @name filterOnReturn
* @summary Require the return key to be pressed to filter a table
* @author [Brian Matovu](http://www.bmatovu.com)
*
* @returns {jQuery} jQuery instance
*
* @example
* $(document).ready(function() {
* var users_dt = $('table[id=tbl_users]').dataTable();
*
* users_dt.filterOnReturn();
* });
*/
jQuery.fn.dataTable.Api.register('filterOnReturn()', function() {
var dt = this;
dt.settings().each(function (setting) {
$.each(setting.aanFeatures.f, function(idx, filter) {
var dtFilterInput = $('input', filter);
dtFilterInput.unbind();
dtFilterInput.bind('keyup', function (event) {
if (event.keyCode == 13) {
dt.search(this.value).draw();
}
});
});
});
});
Loading…
Cancel
Save