Skip to content
This repository has been archived by the owner on Aug 30, 2018. It is now read-only.

Prepend the cart dynamically to element #63

Closed
dominikwilkowski opened this issue May 7, 2014 · 6 comments
Closed

Prepend the cart dynamically to element #63

dominikwilkowski opened this issue May 7, 2014 · 6 comments

Comments

@dominikwilkowski
Copy link
Member

Hi there,

I need to wrap my page into one div as I am using mmenu for a mobile theme. Since ajaxifyShopify prepends the cart to the body it breaks this requirement.

I had a quick look into the source and changed this to make it work:

on line: 273

        // Default settings
        settings = {
            debug: false,
            method: 'drawer', // Method options are drawer, modal, and flip. Default is drawer.
            formSelector: 'form[action^="/cart/add"]',
            addToCartSelector: 'input[type="submit"]',
            cartCountSelector: null,
            cartCostSelector: null,
            toggleCartButton: null,
            btnClass: null,
            wrapperClass: null,
            useCartTemplate: false,
            moneyFormat: '${{amount}}',
            disableAjaxCart: false,
            enableQtySelectors: true,
            prependTo: 'body'
        };

I added the prependTo option

and on line: 461

$(settings.prependTo).prepend(template(data));

I replace the hardcoded 'body' with the added setting.

So I can use it like this

        <script>
            jQuery(function($) {
                ajaxifyShopify.init({
                    prependTo: '.js-cart-container'
                });
            });
        </script>

Hope that helps someone and/or you can roll this into the master.

Cheers

@Cam
Copy link

Cam commented May 7, 2014

I'm having the exact same problem today, while editing the Retina theme for a client. Thank you for your sleuthing and solution :)

Now to just figure out the other strangely hidden conflicts with Retina :/

@dominikwilkowski
Copy link
Member Author

👍

@cshold
Copy link
Contributor

cshold commented May 7, 2014

Great idea. Hadn't thought about the need to append it somewhere else. I'll get on this today and push it with the next release. Thanks.

@cshold
Copy link
Contributor

cshold commented May 7, 2014

Merged #64. Will be pushing a full release shortly (next day or two) with a number of changes/enhancements.

@cshold cshold closed this as completed May 7, 2014
@cshold
Copy link
Contributor

cshold commented May 7, 2014

@Cam Let me know what issues you are running into and if it's something I can help with.

@dominikwilkowski
Copy link
Member Author

Thanks @cshold for the quick merge.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants