Save search form in a Ajax modal

Created on 17 October 2022, about 2 years ago
Updated 27 May 2023, over 1 year ago

Hi!
Is there a way how to show the Save search form using Ajax modal e.g. there ajax link on a page clicking on which shows modal window with the form?
I've tried to investigate code and found the most complex problem - how to get active query $query = $type->getActiveQuery($this->getQueryHelper()); on Ajax call. Any ideas if this somehow possible?

๐Ÿ’ฌ Support request
Status

Active

Version

1.0

Component

Code

Created by

๐Ÿ‡บ๐Ÿ‡ฆUkraine khiminrm

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • ๐Ÿ‡ณ๐Ÿ‡ฑNetherlands Ruuds

    I got here after some googling and didn't find an usable solution. To solve this, I created the Block Button Modal module which shows a button instead of a block, which can be used as a solution for this issue.

    See https://www.drupal.org/project/block_button_modal โ†’

  • ๐Ÿ‡ฆ๐Ÿ‡นAustria drunken monkey Vienna, Austria

    As you have already discovered, getting the active query in an AJAX call (which doesnโ€™t execute the search itself) is very tricky. Youโ€™d probably need to save the most recent search query in the session, or something like that, and that, too, would seem error-prone if someone has multiple tabs open.

    I think a much easier solution, if that would also be acceptable, would be to include the block/form on the page as usual, but hide it with Javascript. Then you just provide a link for displaying the form again, maybe in a modal window if you want.

Production build 0.71.5 2024