Guest User

Untitled

a guest
May 20th, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. $(document).ready(function() {
  2. bind_clicks();
  3. });
  4.  
  5. function bind_clicks() {
  6. $('.add_to_cart_button').click(function(){
  7. add_to_cart(this.id)
  8. });
  9. $('.remove_from_cart').click(function(){
  10. remove_from_cart(this.id)
  11. });
  12. }
  13.  
  14.  
  15. function add_to_cart(id) {
  16. $.post("/cart/add", { id: my_id},
  17. function(data){
  18. $('#cart_info').html(response);
  19. }
  20. );
  21. $('.remove_from_cart').unbind('click');
  22. }
  23.  
  24. function remove_from_cart(id) {
  25. var params = {'_method': 'delete', 'id':id};
  26. $.post("/cart/remove/" + id, params, function(data){
  27. $('#cart_info').html(response);
  28. });
  29. $('.add_to_cart_button').unbind('click');
  30. }
Add Comment
Please, Sign In to add comment