Detecting search input with Javascript

Solved
villet
New Member
2 0 1

Is there a way to get access to product search input with Javascript that works with all themes? Every theme seems to have different HTML for the search input so one selector doesn't work.

Or do I just have to create functionality that tries all selectors that themes use?

0 Likes
Bunty
Tourist
73 16 29

This is an accepted solution.

There are 2 ways to solve it

  • Try to cover all themes and search apps (or start with the most common ones and expand gradually) : This is a never ending game
  • All themes that use native search with post to /search, so either use that in pre scenario or check for page and page parameters in the post scenario (note, this doesn't cover search apps)

Both strategies have trade-offs, so it is up to your use case of what would work best

villet
New Member
2 0 1

Thanks a lot for help!