Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7946459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T01:09:30+00:00 2026-06-04T01:09:30+00:00

Based on this discussion , added code below into my JS code to enable

  • 0

Based on this discussion, added code below into my JS code to enable filtration to be triggered by pressing the enter key instead of keyup or delay.

jQuery.fn.dataTableExt.oApi.fnSetFilteringPressEnter = 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').bind('keypress', function (e) {
            if (e.which == 13) {
                $.fn.dataTableExt.iApiIndex = i;
                _that.fnFilter(anControl.val());
            }
        });
        return this;
    });
    return this;
}

/* Example call */
$(document).ready(function() {
    $('.dataTable').dataTable().fnSetFilteringPressEnter();
} );

Now what I want to do is, when user removes keyword from search bar, I want to redraw table. Currently it doesn’t redraw without pressing enter button. How can I achieve this result?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T01:09:31+00:00Added an answer on June 4, 2026 at 1:09 am

    I think its safe to do on the keyup event of keyboard, unlike only triggering on the enter key press.

    anControl.off('keyup').on('keypress', function (e) {
            $.fn.dataTableExt.iApiIndex = i;
            _that.fnFilter(anControl.val());
    });
    

    Also, note I have used on() and off() for delegation instead of bind and unbind which are deprecated as of jQuery 1.7

    Or, you can create a completely different handler for the specific case, where all the keywords are deleted on the text box.

        anControl.off('keyup').on('keypress', function (e) {
            if (e.which == 13) {
                $.fn.dataTableExt.iApiIndex = i;
                _that.fnFilter(anControl.val());
            }
            if(anControl.val().length == 0) {
                   //redraw table
            }
    
        });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I realize this comes at an enormous risk of being branded subjective and discussion-based,
Based on this question How to insert array into mysql using PDO and bindParam?
This question is based on this thread . The code function man() { man
I am trying to implement macro replacement based on this discussion . Basically it
Based on this discussion, I was wondering if a function scope static variable always
Based on this , how would you make ignoring parameters more succint? var m
Based on this question I understand the purpose of the construct in linking C
Based on this SO post , and this example , I expect that, when
This question is based on this thread . Is [---] a comment in Git
This question is based on this thread . I am interested in how Git

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.