Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

204
Visualizações
"Uncaught TypeError: Cannot read property of undefined" in Shopify Desktop View

I want to display images for a product based on the color options. E.g. If my product is shoes that come in black and white, I want only the black images to appear when the black color option is selected. I have managed to do so by giving the images an alt, adding it to a class, and then showing and hiding the image based on if the alt matches the option. I noticed however for the mobile view that there were more Slick dots and slides than actual images showing. So I solved this by adding slick calls to filter and unfilter slides as I hide and show images giving me this code:

_filterThumbnails: function(variant) {
        
  if (variant.featured_image != null && variant.featured_image.alt != null) {
    $('[data-thumbnail-color]').hide();
    $('.product-single__media-group').slick('slickUnfilter');
    
    var thumbnail_selector = '[data-thumbnail-color="' + variant.featured_image.alt + '"]';
    $(thumbnail_selector).show();
    $('.product-single__media-group').slick('slickFilter',thumbnail_selector);
  }
  else {
    $('[data-thumbnail-color]').show();
    $('.product-single__media-group').slick('slickUnfilter');
  }
},

My problem is that the class I call slick from .product-single__media-group is the same in the desktop and mobile view. So on mobile the function calls slick through that class and works since slick exists for it. However, on desktop, the images are not using slick so the calls will be undefined and ruin the site.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda