# How can I close the popup when a Ninja Form is successfully submitted?

Original URL: https://www.fireplugins.com/docs/troubleshoot/how-can-i-close-the-popup-when-a-ninja-form-is-successfully-submitted/
Last updated: 2025-08-02T23:18:49+03:00

To automatically close your FireBox popup whenever the Ninja Form that’s embedded into your campaign is submitted successfully, please go into your campaign > Advanced > Custom Javascript and add:

 ```
jQuery( window ).on( 'nfFormSubmitResponse', function(e, response, id) {
    if (response.id == '2') {
        const campaign = FireBox.getInstance({fb.id});
        campaign.close();
    }
});
```

 - Replace 2 with your Ninja Form ID.

 Now, whenever the form is submitted, the campaign will automatically close.
