Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(document).on('ready',function(){
- var o = {
- input: $('#item-quantity'), // Input element on modal
- add: function(x){this.i=this.i+x;
- }
- }
- // Execute once the modal show is triggered
- $('#addItem').on('show.bs.modal',function(){
- o.i=1;
- o.input.val(o.i);
- });
- // Execute once the modal fully loads
- $('#addItem').on("shown.bs.modal",function(e){
- // Increment button on click
- $('.more-item').on('click',function(){
- o.add(1);
- o.input.val(o.i);
- });
- // Decrement button on click
- $('.sub-item').on('click',function(){
- if(o.i!=1){o.i-=1;}
- o.input.val(o.i);
- });
- // Modal close button on click
- $('.close').on('click',function(){o.input.val(0);});
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement