Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <button class="buy add-btn" onclick="addCart(this);"> Добавить в корзину</button>
- <input type="hidden" value="<?=$product->id?>" name="id"/>
- <button class="buy add-btn" onclick="addLiked(this);" style="background-image: none;">Добавить в избранное</button>
- function addCart(btn) {
- $this= $(btn);
- $(".shopCart").css({
- backgroundImage:"url(/images/icon/ico-Cartfull.png)",
- backgroundPosition:"14px center",
- backgroundRepeat:"no-repeat"
- });
- var cart_offset = $("#cart").offset(); //координаты корзины
- var cart_img = $this.parents('.item').find('img');
- $('<style id="transferEffect" type="text/css">' + // Add new one
- '.ui-effects-transfer { background-image: url(' + $(cart_img).attr('src') + '); }' +
- '</style>').appendTo('head');
- $(cart_img).effect("transfer",{ clone: cart_img, to: $("#cart") }, 750);
- var id = $this.siblings('input[name=id]').val();
- $.ajax({
- url: '/cart/add_cart',
- dataType : "json",
- type : 'post',
- data : {
- 'id':id
- },
- success: function (data, textStatus) {
- $(".total_count").text(data.total_count+" шт.");
- $(".sum").text(data.total_price);
- $('.name_modal').html(data.addProduct.title);
- $('.price_modal').html(data.addProduct.price);
- $('.img_modal').attr('src','/'+data.addProduct.img);
- $('#myModal').reveal({});
- }
- });
- }
- function addLiked(btn) {
- $this= $(btn);
- var id = $this.siblings('input[name=id]').val();
- alert(id);
- }
- Uncaught ReferenceError: addLiked is not defined
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement