0

i have the following piece of code:

  var search_input = $('#dynatable-search-');
  search_input.on('input', function() {
    console.log('input change detected', search_input.val(), 'and', this.value);
    dynatable.data('dynatable').queries.runSearch(search_input.val());
  });

I would like the search_input to fire runSearch whenever the text inside the input changes. However, I am not having any luck as this is what I am seeing right now:

input change detected and undefined

I don't know why search_input.val() and this.value are both null even though I can see clearly that I am typing something into the input.

3
  • use as `console.log('input change detected', $(this).val(), 'and'); Commented Apr 9, 2014 at 7:07
  • 1
    works fine here jsfiddle.net/r6tD4 Commented Apr 9, 2014 at 7:10
  • Should work fine, the input event catches any change, as in key* and change etc.. Commented Apr 9, 2014 at 7:20

1 Answer 1

1

Use change method instead of input:

var search_input = $('#dynatable-search-');
  search_input.on('change', function() {
    console.log('input change detected', search_input.val(), 'and', this.value);
    dynatable.data('dynatable').queries.runSearch(search_input.val());
  });
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.