I got everything working but it may not be the most elegant of solutions.
I put the form text as well as the empty results div on a page. I created a small plugin that checks to see if we are on that page. If so, insert the JavaScript into the footer. Otherwise, do nothing.
This checks for the page we are on:
public function display_group_information($content)
{
global $post;
if ($post->post_name == 'groups-activities-and-events'){
add_action('wp_footer', [$this, 'load_group_ajax']);
}
return $content;
}
This adds the required javascript:
public function load_group_ajax(){
?>
<script>
!function(r){function n(n).....("#grpSearch").submit(n)}(jQuery);
</script>
<?php
}
Again, probably not the most elegant way of doing it but it works.
Related Posts:
- Allow only new sub-pages to be created
- Add a new page to wordpress programmatically
- AJAX request from Chrome Extension to WordPress Website
- What’s the most minimal way in which a page can be hooked into WP?
- Call the content of a page in AJAX in WordPress
- How to add WP API and JS featured image attachment
- How get get list of pages in ajax search
- Can’t get done anything with admin.php response
- Loading Multiple Comments Pages via Ajax?
- Is it possible to create new user from external form using REST API?
- How To Render Shortcode In AJAX Response?
- Create multiple pages with tables from json file
- register_rest_field only for specific page
- My AJAX requests take 30 seconds to complete
- List of pages – AJAX load more
- How to submit a button automatically after every scheduled hours?
- Dynamic activation page in WordPress
- Post current post type to my Ajax
- How to configure WordPress to handle 75,000 pages?
- How to disable posts and use pages only
- What is the difference between $paged and $page?
- multi page password protection
- Create a “Dummy” parent page for a hierarchy in page listing?
- Retrieving pages with multiple tags using REST API
- Change admin startpage to Pages-page?
- Password protected post or page – error message by wrong password?
- Custom route for WP-API gives “rest_no_route” value
- Get next/previous cousin page
- “rest_no_route” – Debug error
- WordPress 4 and wp_editor() Not Showing Visual/Text tabs
- Get Order of Meta Box in a Page/Post
- Check to see if page exists problems
- Extending wp JavaScript base class to make a post request to a custom REST endpoint
- Custom /page/2/ template (different from index.php)
- wp_localize_script escaping my url – fix or alternative
- Form action redirect to the same page
- Adding rest api endpoints to an old theme
- Front Page not showing on Pages
- WordPress pages with hierarchy
- How to incorporate Documentation into wordpress?
- Develop REST API using WordPress for Android app [closed]
- How to have custom tinyMCE buttons break onto next line when too long
- Get all pages that are published
- Add a predefined page to site
- creating and styling a within a page
- What are trackbacks?
- Weird issue with is_pages() with array
- Missing ‘Page Attributes’ in page edit
- How to control who can view certain pages in BuddyPress? [closed]
- How to add prefix slug in static wordpress page?
- access control for assets in a website powered by wordpress
- How to remove only pages from Admin Bar?
- How to make a page unsearchable in blog search?
- [Zapier + WP Webhooks Pro]: Custom Fields get cut off at first comma or semicolon
- Published pages missing
- Getting ACF Field in Page – From the Footer
- Images are displaying as blank images
- Rewrite to load homepage for a different url
- logout redirect only from admin page
- How to change the order of the Front Page so it doesn’t appear first
- WP AJAX API with JS file
- Static Website No Titles But Still Nav
- Embedding Password Protected (Private) “Blog Posts” BLOCK that shows Images and Excerpts on Password Protected Page (not the home page)
- Template field missing in page attributes
- How to hide a page in wordpress made for menu
- My pages are using my Index.php and not my page.php
- How to change default home link title?
- Adding Amchart Interface to WordPress API
- Deleting media using the WordPress Rest API
- Recovering a page from the drafts
- Pulling images from the media folder category to display inside a page
- My Password Protected Pages Aren’t Working
- How to detect if some page template has been selected
- Best way to make a JSON API from WordPress?
- Page view displays not properly after update wordpress
- Converting HTML to WordPress theme: integrating pages function and using its text editor, conditional enqueuing
- Display custom_post_type with current taxonmy of a page
- How to output different content of page on different places in my template
- WordPress slow pages/post, hangs and white text
- Prevent page from displaying
- Changing title bar in browser window of theme “Encounters Lite”
- Custom Filter using meta_value in wordpress admin list not working
- Loading custom jQuery and HTML in a WordPress page
- Dynamic content in pages
- Javascript will not run properly
- link a custom page into menu
- Show different number of posts on second page of category
- How to login via wordpress api and get user details?
- Find Page Last Modified at Certain Date & Time
- exclude page element from specific pages
- How do I create a page that displays the homepage?
- My homepage is gone but header is still there
- Add tags to long page that is broken up into subpages?
- JS WordPress API fetch no response headers
- How to add page category slug to base url
- Adding Microsoft Teams Incoming Webhook to WordPress, Problem with Rest Route?
- Very strange problem with occasional 404 errors
- WordPress REST API FormData: Form Not Submitted When No Files Attached
- API call from searchbar in wordpress
- Looking for a working code example in python for creating a post