mirror of
https://github.com/billz/raspap-webgui.git
synced 2023-10-10 13:37:24 +02:00
37 lines
962 B
JavaScript
Executable File
37 lines
962 B
JavaScript
Executable File
/**
|
|
* 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 fnFilterOnReturn
|
|
* @summary Require the return key to be pressed to filter a table
|
|
* @author [Jon Ranes](http://www.mvccms.com/)
|
|
*
|
|
* @returns {jQuery} jQuery instance
|
|
*
|
|
* @example
|
|
* $(document).ready(function() {
|
|
* $('.dataTable').dataTable().fnFilterOnReturn();
|
|
* } );
|
|
*/
|
|
|
|
jQuery.fn.dataTableExt.oApi.fnFilterOnReturn = function (oSettings) {
|
|
var _that = this;
|
|
|
|
this.each(function (i) {
|
|
$.fn.dataTableExt.iApiIndex = i;
|
|
var $this = this;
|
|
var anControl = $('input', _that.fnSettings().aanFeatures.f);
|
|
anControl
|
|
.unbind('keyup search input')
|
|
.bind('keypress', function (e) {
|
|
if (e.which == 13) {
|
|
$.fn.dataTableExt.iApiIndex = i;
|
|
_that.fnFilter(anControl.val());
|
|
}
|
|
});
|
|
return this;
|
|
});
|
|
return this;
|
|
};
|