• Resolved ThinkByDesign

    (@thinkbydesign)


    We needed to create links that would pre-populate various fields in the [jobs] shortcode’s search fields.

    I wrote javascript that runs on document ready that finds the field and sets the value (tracing through the JS, I can see this happen). If the URL has been typed or pasted into the address bar, the field gets set and the search results appear just as expected.

    Here’s where I’m running into issues:

    • Navigate to https://locumsagency.wpengine.com/locum-tenens-jobs/
    • Select one of the specialties and see the search results update.
    • From the Jobs link in the topnav or the Locum Tenens Jobs link in the footer, click to see jobs for one of those specialties.
    • Observation: The page will reload. The specialty will actually get changed to the one specified in the query string of the link you clicked (when I step through the code I see it happen), but then some other code – possibly a MutationObserver – changes it back to what it was.
    • Reload the page.
    • Observation: The page now correctly picks up and applies the specialty and does not get switched back.

    Even if I navigate away from the page and then use one of the links to navigate back, it will reset to that same specialty. It was when I encountered this last bit of behavior that I began to wonder if perhaps a cookie was being set by the form, that then gets picked up on page load?

    If anyone has some deeper understanding of what this mechanism is doing, it would be really helpful in building URL’s that can act as shortcuts to specific searches.

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Search field set on document ready getting reverted/unset by (probably) WPJM’ is closed to new replies.