user3522457 user3522457 - 1 month ago 13
CSS Question

close popup after click / submit button trigger in mailchimp

The opt in is catchy and effective I believed but the UX is bad. The user has to manually close the pop-up even after he submitted the email.

How to close the pop up after user submitted the email? Maybe make it delay 1-2 sec after telling the email received.

demo http://codepen.io/anon/pen/Evsmb

<script type='text/javascript'>
(function($) {
window.fnames = new Array();
window.ftypes = new Array();
fnames[0]='EMAIL';
ftypes[0]='email';
window.mc.showPopup = true;
window.mc.delayPopup = 2000;
if (mc.showPopup) mc.evalPopup();
}(jQuery));
var $mcj = jQuery.noConflict(true);
</script>

Answer

Something like this should work.

//Listen for form submit
$('#mc-embedded-subscribe-form').submit(function (e) {

    //hide popup 
    $("#mc_embed_signup").hide();
});

Example: http://jsfiddle.net/Z9qP5/