Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

579
Views
Wordpress + Gravity Forms Ajax + Swup JS

I am using swup.js for page transition and changing content via AJAX. Unfortunately Gravity forms does not seem to be handling the AJAX request well and my form is not working after transitioning.

I am using the following to reinitialize my scripts on page load:

document.addEventListener('swup:pageView', (event) => {
// code 
})

Is there any function I could reinitialize in javascript so Gravity forms would reinitialize on each page transition? Could not find anything in the documentation.

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

I know the date of the post is far, but this question just popped to me and in case you could not find the answer,

try using this code, this will watch any changes applies to the DOM of the body and will trigger whatever you want:

<script>
    $(document).on('DOMSubtreeModified', 'body', function (el) {
        console.log('body content changed');
        // append you init code here
    });
</script>

Tell me if this is working or not.

over 4 years ago · Santiago Trujillo Report

0

Ended up using SwupFormsPlugin and Contact Form 7 with the following

document.addEventListener('DOMContentLoaded', function (event) {
  var domain = window.location.origin // HACK: makes link selector relative
  var isMobile = window.innerWidth < 800
  if (isMobile) {
  } else {
    var swup = new Swup({
      plugins: [
        new SwupOverlayTheme({
          color: '#eff6fb',
          duration: 3000,
          direction: 'to-bottom',
        }),
        new SwupBodyClassPlugin(),
        new SwupFormsPlugin({ formSelector: 'form.wpcf7-form' }),
        new SwupScrollPlugin({
          doScrollingRightAway: false,
          animateScroll: true,
          scrollFriction: 0.3,
          scrollAcceleration: 0.04,
        }),
      ],
      FORM_SELECTOR: 'form.wpcf7-form',
      LINK_SELECTOR: 'a[href*="'.concat(
        domain,
        '"]:not([data-no-swup]), a[href^="/"]:not([data-no-swup]), a[href^="#"]:not([data-no-swup]), a[xlink\\:href]'
      ),
    })
    swup()
  }
})
function domReady (callback) {
  document.readyState === 'interactive' || document.readyState === 'complete'
    ? callback()
    : document.addEventListener('DOMContentLoaded', callback)
}
export { domReady }

Home it helps anyone

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!