O
O
Olga66802020-08-11 16:51:08
JavaScript
Olga6680, 2020-08-11 16:51:08

How to replace slick slider content on click?

Hello! There are two Slick sliders. Vertical with thumbnails and large with replacement when clicking on thumbnails. When you click on the button with options, all photos change to others. But then both sliders stop working. Can you please tell me if this can be fixed? Code:
2 Sliders

<div class="option-thumbnails">
        <ul class="slider-nav">      
          <li><img src="slid1.jpg" title="" alt="" /></li>
        </ul>

  <ul class="slider-for">      
          <li><img src="slid1.jpg" title="" alt="" /></li>
          <li><img src="slid2.jpg" title="" alt="" /></li>
        </ul>
</div>

js
$('.slider-for').slick({
    slidesToShow: 1,
    slidesToScroll: 1,
    fade: true,
    asNavFor: '.slider-nav'
  });
  $('.slider-nav').slick({
    slidesToShow: 3,
    slidesToScroll: 1,
    vertical: true,
    asNavFor: '.slider-for',
    dots: false,
    centerMode: true,
    focusOnSelect: true,
    useCSS: true,
    centerPadding: '100px 0 100px 0',
    swipe: true,
    touchThreshold: 4
  });


js slide photo replacement
$('#product input[type="radio"]').click(function(){
    selectvalue($(this).val());
  });

  function selectvalue(product_option_value_id){
    $.ajax({
      url: 'some'
      type: 'post',
 			dataType: 'json',                   
      success: function(json) {
        if(json['html']){
          $('.option-thumbnails').html(json['html']);
        }
      },
      error: function(xhr, ajaxOptions, thrownError) {
        alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
      }
     });
  }

html replacement code

<ul class="slider-nav">      
          <li><img src="slid3.jpg" title="" alt="" /></li>
        </ul>

  <ul class="slider-for">      
          <li><img src="slid3.jpg" title="" alt="" /></li>
          <li><img src="slid4.jpg" title="" alt="" /></li>
        </ul>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
ThunderCat, 2020-08-11
@ThunderCat

Isn't it easier to make another block with 2 slicks and hide it, and stupidly show it on the button and hide the first set?

O
Olga6680, 2020-08-11
@Olga6680

I thought about that. But there are several sets. And every page is different. I can't figure out how to do this. Is AJAX not real? Can you change the html? This is for the product card. So that when you change the color option, the photo changes

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question