0

My Shopify store uses Ajax call's to add products to the cart and jQuery to update the front-end. I recently installed infinite-ajax-scroll but this brought some issues.

The store gets "ajaxified" by this call on the homepage:

jQuery(function($) {
  ajaxifyShopify.init({
    method: '{{ settings.ajax_cart_method }}',
    wrapperClass: 'wrapper',
    formSelector: '#addToCartForm',
    addToCartSelector: '#addToCart',
    cartCountSelector: '#cartCount',
    toggleCartButton: '.cart-toggle',
    useCartTemplate: true,
    btnClass: 'btn',
    moneyFormat: {{ shop.money_format | json }},
    disableAjaxCart: false,
    enableQtySelectors: true
  });

The full code is located here: http://cdn.shopify.com/s/files/1/0656/8697/t/7/assets/ajaxify.js?9594

I'm wondering what it does exactly and who it belongs to.

I want to know so I can unbind the initialised code from the page to solve this problem.

Community
  • 1
  • 1
narzero
  • 2,199
  • 5
  • 40
  • 73
  • *Brought some issues* what issues do you mean? – Mohammad Areeb Siddiqui Oct 18 '14 at 13:05
  • 2
    At least try a google search before you post questions... – T J Oct 18 '14 at 13:08
  • @MohammadAreebSiddiqui this issue: http://stackoverflow.com/questions/26438825/how-do-i-unbind-a-this-piece-of-jquery – narzero Oct 18 '14 at 13:11
  • @TJ How do you know I didn't? For someone completely new to jQuery, `jQuery(function() {} );` and `$(function() {} );` is not the same. So reading http://stackoverflow.com/questions/7642442/what-does-function-do does not make sense. – narzero Oct 18 '14 at 13:14
  • @narzero then i suggest going through some tutorials and learning the basics first rather than posting questions one another. SO requires a minimal understanding of the language you're asking about. – T J Oct 18 '14 at 13:26

1 Answers1

1
jQuery(function(){}) // or $(function(){})

is the short for DOM ready

jQuery(document).ready(function(){

});

So, it is where it belongs.

Also, use of jQuery might be to avoid conflict between the usage of $ in jQuery and other libraries. So, if that is the case, I'd avoid the use of $ and instead go with jQuery

Amit Joki
  • 58,320
  • 7
  • 77
  • 95
  • It's technically a short for `jQuery(document).ready(function(){`. In this case `jQuery` and not `$` was used probably to avoid conflict with other libraries using the `$` symbol. – Terry Oct 18 '14 at 13:11
  • @Terry ok. Used jQuery as was in the question. Thanks btw – Amit Joki Oct 18 '14 at 13:14
  • Thanks for giving a clear answer without jumping to conclusions about my jQuery knowledge and whether or not I've searched for the answer. – narzero Oct 18 '14 at 13:19
  • 1
    @narzero also, see the edit. Glad to have helped you. Also don't mind them, they only tried to help you :) – Amit Joki Oct 18 '14 at 13:21