Sha256: 2c2462197f61a5cc95c7cab5a50733577880809cdd6f4b3ff31ffb5034c16b77
Contents?: true
Size: 1.12 KB
Versions: 21
Compression:
Stored size: 1.12 KB
Contents
//= require spree/frontend/viewport Spree.fetchRelatedProducts = function (id, htmlContainer) { return $.ajax({ url: Spree.routes.product_related(id) }).done(function (data) { htmlContainer.html(data) htmlContainer.find('.carousel').carouselBootstrap4() }) } document.addEventListener('turbolinks:load', function () { var productDetailsPage = $('body#product-details') if (productDetailsPage.length) { var productId = $('div[data-related-products]').attr('data-related-products-id') var relatedProductsEnabled = $('div[data-related-products]').attr('data-related-products-enabled') var relatedProductsFetched = false var relatedProductsContainer = $('#related-products') if (!relatedProductsFetched && relatedProductsContainer.length && relatedProductsEnabled && relatedProductsEnabled === 'true' && productId !== '') { $(window).on('resize scroll', function () { if (!relatedProductsFetched && relatedProductsContainer.isInViewport()) { Spree.fetchRelatedProducts(productId, relatedProductsContainer) relatedProductsFetched = true } }) } } })
Version data entries
21 entries across 21 versions & 1 rubygems