Skip Navigation

[Resolved] Automatic Ajax Search after user stops typing in search field

This support ticket is created 6 years, 5 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 2 replies, has 2 voices.

Last updated by Jan Thielemann 6 years, 5 months ago.

Assisted by: Christian Cox.

Author
Posts
#1088366

I have a Ajax view with some dropdowns, checkboxes and a textfield to search in post title and content. Whenever I change somethin in one of the fields, the Ajax search runs and filters the result. Only if I enter some text, I have to press return to start the filter process.

Is there an option to automatically start filtering after the user stops typing? Would it work if I trigger a certain event on the textfield using jQuery?

#1088673

Hi, there's no option to trigger an update without pressing enter or tabbing out. I can't guarantee performance or effectiveness using updates on key events because Views isn't designed to work this way, but you can try it at your own risk. Using your own custom JavaScript, you can trigger an AJAX update by triggering a generic "change" event on any input in the search form with the js-wpv-filter-trigger class.

...
jQuery('.js-wpv-filter-form-12345 .js-wpv-filter-trigger:first').trigger('change');
...
#1088688

Thanks, I'll try this in combination with a timeout so that it is not refreshed on every keystroke but rather shortly after the user stops typing.