简体   繁体   English

更改Jssor Slider中的幻灯片集

[英]Change slide set in Jssor Slider

I have a website with a JSSOR Slider and three icons below it. 我有一个带有JSSOR滑块和下面三个图标的网站。 When I click on an icon I need it to load a certain set of images in the slider. 当我单击图标时,我需要它在滑块中加载一组特定的图像。 When I click on another icon, I need to load a different set of images and remove the first. 当我单击另一个图标时,我需要加载另一组图像并删除第一组。

So far I've tried to hide the images I'm not using, etc. I was able to do this, except the thumbnails are still there and load blank slides where I hid the images. 到目前为止,我已经尝试隐藏不使用的图像,等等。我能够做到这一点,只是缩略图仍然存在,并在我隐藏图像的地方加载了空白幻灯片。

How do you change the slide set without loading three sliders into the page? 如何在不将三个滑块加载到页面的情况下更改幻灯片组?

Thanks for any help. 谢谢你的帮助。

Yes, you can refresh content of any slide manually. 是的,您可以手动刷新任何幻灯片的内容。 See jssor slider: How to reload/refresh the slider to show new images 请参阅jssor滑块:如何重新加载/刷新滑块以显示新图像

But in this manner, you can not refresh thumbnails. 但是以这种方式,您无法刷新缩略图。 As there are thumbnails of every slider, The best way is to load 3 sliders at the beginning with lazy loading manner, show 1 and hide another 2. 由于每个滑块都有缩略图,因此最好的方法是,以延迟加载的方式在开始时加载3个滑块,显示1并隐藏另外2个。

Use following format (src2="url") to define lazy loading slide, 使用以下格式(src2 =“ url”)定义延迟加载幻灯片,

<div><img u="image" src2="url" /></div>

Btw, not sure if the nested slider (3 child sliders in a main slider) meet your needs. 顺便说一句,不确定嵌套滑块 (主滑块中的3个子滑块)是否满足您的需求。

The question has been asked long time back but I recently came across a similar problem where I want to click on an image and load a set of images for slider and one clicking another image, load another set of slider. 这个问题已经问了很久了,但是最近我遇到了一个类似的问题,我想单击一个图像并加载一组图像用于滑块,然后单击另一个图像,加载另一组滑块。 this is what I did and it worked for me and hence sharing as it can benefit others. 这就是我所做的,对我有用,因此可以分享,因为它可以使他人受益。

<ul class="row">
  <li class="col-xs-3 col-md-3">
     <div class="thumbnail">
         <img id="workone" src="imageone.jpg" alt="" width="300px" height="250px"> 
     </div>
  </li>      
  <li class="col-xs-3 col-md-3">
     <div class="thumbnail">
        <img id="worktwo" src="imagefour.jpg" alt="" width="300px" height="250px">  
      </div>
   </li>
  </ul>

On clicking workone I want to load a page slider.html that has a jssor slider with a set of images and on clicking worktwo, I want to load another set of images for the same slider. 在单击工作对象时,我想加载一个页面slider.html,该页面具有一个包含一组图像的jssor滑块,在单击工作对象时,我想为同一滑块加载另一组图像。 The javascript for this html is 这个html的javascript是

$(document).ready(function() {
    $('#workone').click(function()
    {
        localStorage.setItem('set', 1);
      window.location = "slider.html"; 
    });
    $('#worktwo').click(function() {
        localStorage.setItem('set', 2);
      window.location = "slider.html";          
    });
}); 

I added an id to the image divs in the jssor slider code. 我在jssor滑块代码中向图像div添加了一个id。 Something like this 像这样

<div data-u="slides" style="cursor: default; position: relative; top: 0px; left: 0px; width: 600px; height: 500px; overflow: hidden;">
<div style="display: none;">
   <img id="imageone" data-u="image" src="img/01.jpg" />
</div>
<div style="display: none;">
  <img id="imagetwo" data-u="image" src="img/02.jpg" />
</div>
<div style="display: none;">
    <img id="imagethree" data-u="image" src="img/03.jpg" />
</div>
<div style="display: none;">
<img id="imagefour" data-u="image" src="img/04.jpg" />
</div>

and than changed the image set in javascript with the below code. 然后使用以下代码更改了javascript中设置的图片。

 $(document).ready(function() {
    x = localStorage.getItem('set');
    console.log(x);
    if (x === '2')
    {
    $('#imageone').attr('src','img/05.jpg');        
      $('#imagetwo').attr('src','img/06.jpg');
      $('#imagethree').attr('src','img/07.jpg');
      $('#imagefour').attr('src','img/08.jpg');

     } })

This worked perfectly fine for me 这对我来说很好

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM