Emil Devantie Brockdorff
Emil Devantie Brockdorff

Reputation: 4954

jQuery Colorbox: Close Colorbox on press submit button

I’m working on inserting a MailChimp subscribe form inside the jQuery Colorbox modal window. I’ve got everything to work but I can’t figure out how to close the Colorbox when submitting the subscribe form.

I’ve been looking at Colorbox website and other questions here at Stackoverflow but haven’t got it to work. What I’ve got so far is:

Inside I’ve added

<script type="text/javascript">
$(document).ready(function(){
$('#cboxContent .closebutton').live('click', function(){
$.fn.colorbox.close();});
});
</script>

Then, in my Newsletter Form, I’ve added the class “closebutton” to my submit button, so it look like this:

<input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="closebutton"></div>

But I doesn’t work.
What am I doing wrong?

Sincere - Mestika

Upvotes: 0

Views: 1905

Answers (3)

jonathan
jonathan

Reputation: 114

later of try and try, and see various forums or always in stackoverflow, the function to close that worked for me is this

    $("#edit-next").click(function(e) {
        e.preventDefault();
        window.parent.jQuery.colorbox.close();
        this.submit;
    }); 

You can change the click to submit and working good, this also working for drupal, i find this example in the page of the creator of colorbox.

resource http://www.jacklmoore.com/colorbox/faq/#faq-close

Upvotes: 0

Christina
Christina

Reputation: 34652

$(window).load(function () {
        $('#signupform').submit(function(){
       parent.jQuery.fn.colorbox.close()
    });
});

I made the inline content with the mailchimp signup form have the id "signupform".

Upvotes: 0

Jack
Jack

Reputation: 9538

Is the subscribe form inside of an iframe? If so, you would need to call $.colorbox.close from the parent object. Example:

parent.$.colorbox.close();

Also, you may want to handle this a different way than on button press. You should verify that the form has been successfully submitted before closing the form.

Upvotes: 1

Related Questions