简体   繁体   English

将Jquery滑块与模式弹出窗口结合使用时的问题

[英]An issue with combining a Jquery slider with modal pop-ups

I'm building a Timeline / Map. 我正在建立时间轴/地图。 It's a map with a slider at the top; 这是一张顶部带有滑块的地图。 when you drag the slider, different icons show up on the map that can be clicked to engage modal pop-ups (it also displays overlays on the map). 拖动滑块时,地图上会显示不同的图标,可单击这些图标以启用模式弹出窗口(它还会在地图上显示叠加层)。 It works wonders and looks Beautiful, EXCEPT one thing: On load, EVERYTHING is displayed. 它能产生奇迹,看起来很漂亮,除了一件事:加载时,显示一切。 How can I get it to default to the first date on the map as the only icons and overlaps that are displayed? 如何将其默认设置为地图上的第一个日期,因为它仅显示图标和重叠部分?

The code is below, but I am not much for code and can't figure out what I'm doing wrong: 下面的代码,但是我对代码的要求不高,无法弄清楚我在做什么错:

there's a list of like 500 IDs like this 有一个像这样的500个ID的列表

var popups = [ {id:"cultarg1969a", start:1969, end:1969},

then there's this: 然后是这样的:

 $(document).ready(function() {
  $("#slider").slider({
    min: 1491,
    max: 2020,
    step: 1,
    value: 1491,
  });


$( "#slider" ).bind( "slide", function(event, ui) {
    $(".category1,.category2,.category3,.category4,.category5,.iso").hide();
 $("#yearIndicator").text(ui.value);            
        for (var index=0;index<popups.length;index++) {
        var popup = popups[index];
        if (ui.value >= popup.start && ui.value <= popup.end) {
    $("#" + popup.id).show();
    }
} 
});

  $("#0").addClass("selected");

}); 

I just want the items for year 1491 to show up when the page loads. 我只希望页面加载时显示1491年的项目。 What am I doing wrong? 我究竟做错了什么? thank you. 谢谢。

My guess is that you probably want each of the elements in the popups array to initially be hidden, which is most easily done by having display: none in their initial CSS. 我的猜测是,您可能希望最初隐藏popups数组中的每个元素,这最简单的方法是通过display: none在其初始CSS中display: none The .show() call should override that display property when the time comes to show it. 当需要display时, .show()调用应覆盖该display属性。

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

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