Skip to content

Instantly share code, notes, and snippets.

@yajra
Created November 26, 2015 06:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yajra/5b6721e2023386bbc4ac to your computer and use it in GitHub Desktop.
Save yajra/5b6721e2023386bbc4ac to your computer and use it in GitHub Desktop.
DataTables fnFilterOnReturn plugin
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;
};
$(function () {
$('.dataTables_wrapper table').dataTable().fnFilterOnReturn();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment