0

We have a single page app that pre-loads records for editing within a Cognito form. The form is populated by passing in values with an entry object.

How can we clear the previously loaded Cognito form and send it a new entry object, without reloading the page?

The following JQuery removes the prior form.

$(".cognito").html("");

We then call the form init again:

var formID = 1;
var entryObj = {"Name": { "First": "Ima", "Last": "Nexta" }};
Cognito.load("forms", { id: formID, entry: entryObj });

But a new form is not rendered.
Only the form's title, description and Submit button appear.

1

The easiest method would be to use the iframe embed option and reload it when you would like to create a new entry. You can use the iframe prefill to populate defaults for the new entry data.

There is a method that involves a bit more JavaScript that works with the seamless embed, but it requires some form and organization specific data. Feel free to contact support directly via the support link within the application if you need additional help.

Disclaimer: I am a developer on the Cognito Form team

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.