Advertisement
Guest User

Untitled

a guest
Jul 24th, 2016
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. $(document).on('ready',function(){
  2. var o = {
  3. input: $('#item-quantity'), // Input element on modal
  4. add: function(x){this.i=this.i+x;
  5. }
  6. }
  7.  
  8. // Execute once the modal show is triggered
  9. $('#addItem').on('show.bs.modal',function(){
  10. o.i=1;
  11. o.input.val(o.i);
  12. });
  13.  
  14.  
  15. // Execute once the modal fully loads
  16. $('#addItem').on("shown.bs.modal",function(e){
  17.  
  18. // Increment button on click
  19. $('.more-item').on('click',function(){
  20. o.add(1);
  21. o.input.val(o.i);
  22. });
  23.  
  24. // Decrement button on click
  25. $('.sub-item').on('click',function(){
  26.  
  27. if(o.i!=1){o.i-=1;}
  28. o.input.val(o.i);
  29. });
  30.  
  31. // Modal close button on click
  32. $('.close').on('click',function(){o.input.val(0);});
  33.  
  34. });
  35. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement