Skip to content

Instantly share code, notes, and snippets.

@objectivehtml
Created November 8, 2012 18:15
Show Gist options
  • Select an option

  • Save objectivehtml/4040531 to your computer and use it in GitHub Desktop.

Select an option

Save objectivehtml/4040531 to your computer and use it in GitHub Desktop.
$('.add-to-cart').submit(function(e) {
var form = $(this);
var action = form.attr('action');
var post = {};
var urlTitle = FilterFarm.segment(3);
form.find('input, select, textarea').each(function() {
var $t = $(this);
post[$t.attr('name')] = $t.val();
});
$('.cart-activity').css({
display: 'inline-block'
});
$.post(action, post, function() {
$.get('/store/cart/'+urlTitle, function(html) {
$('.popover').html(html);
$('a.cart').addClass('active').html($('.popover .total').html()+'<span class="icon-shopping-cart"></span>');
$('.popover').fadeIn();
$('.cart-activity').hide();
});
}, 'JSON');
e.preventDefault();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment