Created
August 27, 2019 01:13
-
-
Save chrismcintosh/f390f9a3985d635290b25f67476e024e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// get all instances of a form on the post | |
const matches = document.querySelectorAll(".gform_wrapper form") | |
// we are using vue.js here with the slug of the current post in state | |
const slug = store.state.currentPost.slug | |
// loop through each form on the post | |
matches.forEach(function(match) { | |
// get the value of the id of the form | |
let gformID = match.getAttribute("id") | |
// get only the form number off the gravity form using regex | |
let isolatedID = /([1-9][0-9]*)/.exec(gformID) | |
// set the action of the current form using the slug and the current form id | |
match.setAttribute("action", `/${slug}/#gf_${isolatedID[0]}`) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment