How To Use; In Custom Add To Cart Success To Open Drawer?

- 1 answer

I am using add to cart with custom ajax code and its working fine, problem is I need to open cart drawer on success function by using; For now I am using "js-drawer-open-right" class in form but its open drawer same time when click on add to cart button. I need to open drawer on success of add to cart.

My Ajax code is:

                function addItem(button) {
                var postData = $(button).closest('.add-to-cart').serialize();
                    type: 'POST',
                    url: '/cart/add.js',
                    dataType: 'json',
                    data: postData,
                    success: addToCartOk,
                    error: addToCartFail
                function addToCartOk(product) {
                //Want to open drawer here on success
                function addToCartFail(obj, status) {

My form is:

Here you can check Add to Cart



I have find out different and very easy solution for this as compare to;

I have clicked "js-drawer-open-right" with jQuery in success function and removed that class from form which I have placed before.

The success function now is:

         function addToCartOk(product) {
            //drawer open here by click on that class on success

Its worked perfectly fine.