Advertisement
Guest User

Untitled

a guest
Feb 20th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. <button class="buy add-btn" onclick="addCart(this);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Добавить в корзину</button>
  2.  
  3. <input type="hidden" value="<?=$product->id?>" name="id"/>
  4.  
  5. <button class="buy add-btn" onclick="addLiked(this);" style="background-image: none;">Добавить в избранное</button>
  6.  
  7. function addCart(btn) {
  8. $this= $(btn);
  9. $(".shopCart").css({
  10. backgroundImage:"url(/images/icon/ico-Cartfull.png)",
  11. backgroundPosition:"14px center",
  12. backgroundRepeat:"no-repeat"
  13. });
  14. var cart_offset = $("#cart").offset(); //координаты корзины
  15. var cart_img = $this.parents('.item').find('img');
  16. $('<style id="transferEffect" type="text/css">' + // Add new one
  17. '.ui-effects-transfer { background-image: url(' + $(cart_img).attr('src') + '); }' +
  18. '</style>').appendTo('head');
  19. $(cart_img).effect("transfer",{ clone: cart_img, to: $("#cart") }, 750);
  20.  
  21. var id = $this.siblings('input[name=id]').val();
  22.  
  23. $.ajax({
  24. url: '/cart/add_cart',
  25. dataType : "json",
  26. type : 'post',
  27. data : {
  28. 'id':id
  29. },
  30. success: function (data, textStatus) {
  31. $(".total_count").text(data.total_count+" шт.");
  32. $(".sum").text(data.total_price);
  33. $('.name_modal').html(data.addProduct.title);
  34. $('.price_modal').html(data.addProduct.price);
  35. $('.img_modal').attr('src','/'+data.addProduct.img);
  36. $('#myModal').reveal({});
  37. }
  38. });
  39. }
  40.  
  41.  
  42.  
  43. function addLiked(btn) {
  44. $this= $(btn);
  45.  
  46.  
  47.  
  48. var id = $this.siblings('input[name=id]').val();
  49. alert(id);
  50.  
  51. }
  52.  
  53. Uncaught ReferenceError: addLiked is not defined
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement