Hey Guys and Gals,
I am have created a fixed subscribe bar that contains a brief message and blog subscription form that slides down and fixes itself to the bottom of the screen after 15 seconds of being on one of our blog pages. I want the whole bar to dissapear and slide off screen on the successful submission of the form. Something I can get to work on non-hubspot forms but for some reason the hubspot form is giving me a difficult time. Any help would be appreciated.
Here is the HTML:
<div class="sub-container " id="hideMe">
<div class="sub-wrapper clearfix">
<div class="sub-form-left">
<span class="text">Stay current on the latest manufacturing marketing trends!</span>
<span class="mobile-text">Stay Informed</span>
</div>
<div class="sub-form-right">
{% blog_subscribe "subscribe_designers_blog" select_blog="(myBlogID)", no_title=true , response_message="Thanks for Subscribing!", label="Blog Email Subscription", overrideable=False %}
</div>
</div>
</div>
The CSS (no media queries):
/* fixes container to position on screen and sets size */
.sub-container {
position: fixed;
bottom: 0;
left: 0;
display: none;
width: 100%;
height: 50px;
}
/*sets background color and clears any floats */
.sub-wrapper {
position: relative;
width: 100%;
height: 100%;
background-color: #333;
color: #fff;
}
/* floats section to left and sets contianer width */
.sub-form-left {
position: relative;
display: block;
float: left;
width: 60%;
height: 100%;
}
/* verticaly and horizontally center text section */
.sub-form-left .text {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 100%;
text-align: center;
}
.sub-form-left .mobile-text {
display: none;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 100%;
text-align: center;
}
/* floats section right and sets container width */
.sub-form-right {
display: block;
position: relative;
float: left;
width: 40%;
height: 100%;
}
/* centers the form vertically delete width property to center H */
.sub-form-right form.hs-form {
width: 100%;
margin: 0;
padding: 0;
display: block;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
/* allows the form to display inline */
.input, .actions,
.hs_email.hs-email.hs-fieldtype-text.field.hs-form-field,
.hs_submit.hs-submit {
display: inline-block;
margin: 0;
padding: 0;
}
.sub-form-right .hs-button-primary,
.sub-form-right input[type="submit"],
.sub-form-right input[type="button"] {
display: inline-block;
width: 100px;
color: #fff;
background-color: #9f218b;
border-radius: 5px;
letter-spacing: 1px;
}
.sub-form-right .hs-button-primary:hover,
.sub-form-right input[type="submit"]:hover,
.sub-form-right input[type="button"]:hover {
display: inline-block;
width: 100px;
color: #fff;
background-color: #9f218b;
border-radius: 5px;
}
.sub-form-right input[type="email"] {
display: inline-block;
width: 200px;
margin: 0;
border-radius: 5px;
}
.submitted-message {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.hs-form label {
display:none;
}
and the Javascript:
$(function() {
setTimeout(function() {
$('#hideMe').slideDown(300);
}, 15000);
hbspt.forms.create({
portalId: '(myPortalId)',
formId: '(myFormId)',
css: '',
onFormSubmit: function($form) {
$('#hideMe').slideUp(300);
}
}); //end Create
}); //end ready
.on(submit, function() {…} Doesnt seem to work for me with hubspot forms and someone else suggested that I try working it the way that I did here but that doesnt seem to be working either. Any help would be appreciated!
Thank you in advance!
-BJ