Search query only added to url if ajax is disabled

Created on 4 September 2023, 10 months ago
Updated 19 September 2023, 9 months ago

When using search_api module with views I understand that by default the entered query should be appended to the url after hitting the submit button

e.g.

search?search_api_fulltext=business

However when I have ajax enabled on the view, this is not working as expected, and no query string is added to the url

πŸ’¬ Support request
Status

Fixed

Version

1.29

Component

General code

Created by

πŸ‡¬πŸ‡§United Kingdom 2dareis2do

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @2dareis2do
  • πŸ‡³πŸ‡±Netherlands idebr

    For AJAX to update the URL you can install this contrib module: https://www.drupal.org/project/views_ajax_history β†’

  • πŸ‡¬πŸ‡§United Kingdom 2dareis2do

    Thanks!

    I was thinking of creating a module called search_api_views_ajax, having now having seen view_ajax_history I not sure this is necessary any longer.

    I was struggling to see how to enable it as there is no README with the module but figured it out and can confirm it works well with Apache Solr. I like the ability to switch on and off for each view. I have attached a screenshot for other who might be wondering where to find the switch.

  • Status changed to Fixed 10 months ago
  • πŸ‡³πŸ‡±Netherlands idebr
  • πŸ‡¬πŸ‡§United Kingdom 2dareis2do

    Ok, I have evaluated the views_ajax_history module, and while it works reasonably well it has a couple of issues.

    1. it adds page pagination to the ajax query. This is not something that can be easily disabled. One consequence of this is that when navigating back to the view form another page invariably the page will reload and will only show the page in the query string. Although you can force the view to load all results this does come with a performance hit (especially for larger indexes).
    2. I had n't really considered this behaviour until looking at views_ajax_history, but when clicking the browser back button it does not seem to load the current page context (search query string) without doing a manual browser refresh

    So, I decided to write something that addresses these issues, namely only really handling the search query string when using the a 'full text search field'. This should work across all ajax enabled sites once the search_api_ajax_views module is enabled. Additionally results should be updated asynchronously when navigating back through the history.

    https://www.drupal.org/project/search_api_views_ajax β†’

    Hopefully this will help others with similar requirements.

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.69.0 2024