Forums › Forums › Search & Filter Pro › align two search forms with executed search
- This topic has 4 replies, 2 voices, and was last updated 8 years, 11 months ago by Ross.
-
Anonymous(Private) November 19, 2015 at 12:11 pm #30174
Hi there,
Really enjoying your plugin so far. With just a few clicks I am almost where I want to be with a much improved search user experience.
I’m wondering, is it possible to keep the search text in sync across two forms. I’ve tried enabling shortcodes, maintaining state, bookmarkable, native form, but to no avail. Maybe because they are two separate forms, they remember their own value only.
Here is the situation: I have one simple form with search field in the header that leads to the results page. And on the results page I have another more detailed form with search field and filters in the sidebar. Only the first time when I submit one of the forms, the other one picks it up on the results page. But after that they stick to what you’ve entered. It doesn’t updated the other one. I was hoping either form could pick up the executed search, instead of remembering their old value.
Is this possible at all? I hope I’m explaining myself clearly.
Thanks for your advice,
Bram
Ross Moderator(Private) November 19, 2015 at 12:19 pm #30176Hey Bram
Are you using ajax? In this case I’m afraid not.
What you would need to is write some jQuery code, to detect when
.searchandfilter input[type=text]
is updated, and when it is, copy the val of that to all other instances on the page.Alternatively, if you have bookmarkable URLs enabled, and Ajax disabled, then they will use the same URL variable to populate the search field.
Thanks
Anonymous(Private) November 20, 2015 at 3:31 pm #30322I came up with this little snippet that works quite good for now.
$( "body" ).on( "change", ".searchandfilter input[type=text]", function() { $('.searchandfilter input[type=text]').val( $( this ).val() ); });
The ‘change’ event only fires on blur, but fortunately your plugin blurs the search field when submitting the form through ajax so that works well.
-
AuthorPosts