I'm working with WordPress Gravity Forms plugin. I loaded a form into a jquery dialog and I want to have the dialog to close after form submission instead of reloading the page.
However, I don't know, if it is possible to add preventDefault()
into submit()
event. Or if there is an option not to reload the page in the Gravity Forms.
Please, advise me a possible way to achieve it.
I'm working with WordPress Gravity Forms plugin. I loaded a form into a jquery dialog and I want to have the dialog to close after form submission instead of reloading the page.
However, I don't know, if it is possible to add preventDefault()
into submit()
event. Or if there is an option not to reload the page in the Gravity Forms.
Please, advise me a possible way to achieve it.
Share Improve this question edited Apr 13, 2018 at 22:04 Samvel Aleqsanyan 2,9744 gold badges21 silver badges28 bronze badges asked Apr 25, 2015 at 10:48 lightbringerlightbringer 8352 gold badges12 silver badges24 bronze badges3 Answers
Reset to default 2You could try targeting an invisible iframe.
<form action="this_action.php" method="post" target="iframe">
<input type="submit" value="Submit" />
</form>
<iframe name="iframe" style="position: absolute; visibility: hidden"></iframe>
Do you have the Enable AJAX options checked?
Look at https://web.archive/web/20150415003507/http://www.gravityhelp.:80/documentation/gravity-forms/user-guides/getting-started/embedding-a-form/: this will submit your form without a page refresh.
Then just call the dialog close in the submit event and you are done!
Making AJAX True along with the shortcode did the trick for me.
[gravityform id="2" title="true" ajax="true"]