Q:

Rails: Foundation 5 Reveal Modal to Submit Button

I have a form in which half of it is on a "Targeting" Reveal Modal. For example, the user will fill out certain fields in the form, click a next (in which is named "Define Targeting") button in which a modal pops up to finish the form.
When they click the "Done" submit button, I would like it to save and close the modal and stay on the main form page.
The issue I am having is that it does not save my record as long as I have the class: "close-reveal-modal". When removed, it saves the record but it does then I lose it's ability to close the modal.
Here is the submit button..
<%= f.submit "Done", class: "close-reveal-modal", remote: true %>

..and extra Javascript to trigger the submit.
$(document).ready(function(){
    $(".close-reveal-modal").click(function(){

        var isSelected = $("#campaign_plan_id").val();

        if (isSelected.length > 0){
            $('form#new_campaign').trigger('submit.rails');
            $("#target-button").hide();
            $("#campaign-create-button").css("display", "block").css("background-color", "#E37368");
        }
    });
}) 

Let me know if more clarity is needed and I'd be happy to add to the post. I'm learning Zurb through this process and Javascript isn't necessarily my forte. 

A:

Change the class name to sth like close-button and then:
$(document).ready(function(){
    $(".close-button").click(function(){

        var isSelected = $("#campaign_plan_id").val();

        if (isSelected.length > 0){
            $('form#new_campaign').trigger('submit.rails');
            $("#target-button").hide();
            $("#campaign-create-button").css("display", "block").css("background-color", "#E37368");
        }

        $(this).closest('[data-reveal]').foundation('reveal', 'close');
    });
}) 

