Skip to content

Instantly share code, notes, and snippets.

@msmithstubbs
Last active December 15, 2015 20:19
Show Gist options
  • Select an option

  • Save msmithstubbs/5317489 to your computer and use it in GitHub Desktop.

Select an option

Save msmithstubbs/5317489 to your computer and use it in GitHub Desktop.
<script>
$(function() {
$('.notify_form [type=submit]').click(function(e) {
e.preventDefault();
var variantId = $('select[name=id]').val() || {{ product.variants.first.id }};
var email = $(this).closest('form').find('[name="contact[email]"]').val();
var showResponse = function(text) {
var form = $(e.target).closest('form');
form.find('.BIS_feeback').remove();
form.append($('<p class="BIS_feeback">').text(text));
};
BISPopover.create(email, variantId)
.then(function(data) {
if (data.status == 'OK') { showResponse(data.message) }
else {
var msg = [];
for(var i in data.errors) {
msg.push(data.errors[i]);
}
showResponse(msg.join("\n"));
}
});
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment