Repository navigation
Alternate Success Markup from a Template or Existing Div after AJAX Submit #80
Answered
by
gustavs-gutmanis
TUSAB-web
asked this question in
Questions & Answers
|
I am looking at this page in the docs: If I have 2 forms on one page, would I have the script on the bottom repeated with the different div IDs, or just add another line of the div IDs into the same script... referring to this line specifically: |
Answered by
gustavs-gutmanis
Jan 8, 2021
Replies: 1 comment
|
If both your forms need to show the same div's contents, can get by with a single script for both. First off - change the wrapper to have no ID specified at all <div>
{{ craft.freeform.form('myContactForm').render }}
</div>Then modify the script to have this code: <script type="text/javascript">
document.addEventListener('freeform-render-success', function (event) {
event.preventDefault();
var form = event.form;
$(form).parent().html($('#custom-content').html());
});
</script> |
0 replies
Answer selected by
kjmartens
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If both your forms need to show the same div's contents, can get by with a single script for both.
First off - change the wrapper to have no ID specified at all
Then modify the script to have this code:
Notice that I changed the
document.ontodocument.addEventListener. The docs will be updated with this change very soon