How a change the default input search?

How a change the default input search?

rodz25rodz25 Posts: 1Questions: 1Answers: 0
edited February 10 in Free community support

I need implement a change on serach to retorn any term tha I input separated by commas.

I tryed use:

$('#myInput').on( 'keyup', function () {
var searchString = $(this).val();
var searchTerms = searchString.split(',');
var regexString = searchTerms.map(term => (?=.*${term})).join('');
table.search(regexString, true, false).draw();
} );;

and change the "my input" to "#myTable_filter label input" but dident worked.

Answers

  • colincolin Posts: 15,152Questions: 1Answers: 2,587

    You can't just repurpose the search input, without disabling the existing behaving first. This example here is doing that, it uses off() to prevent the standard search - try doing that first.

    Colin

  • allanallan Posts: 61,744Questions: 1Answers: 10,111 Site admin

    I'd suggest you remove the default input element and replace it with your own. The other option would be to unbind DataTables event listeners on that element and then add your own, but I think simply replacing the element would be the easiest option.

    Allan

Sign In or Register to comment.