2016-02-05 87 views
1

我正在使用jQuery滑块,但无法移动手柄。jQuery Mobile - 滑块无法移动

的HTML结构:

<div id="map" class="map" style="position: relative;"> 
    <div id="legend" class="legend" style="position: absolute; top: 0px; right: 0px; width:300px; z-index: 100;"> 
    <div style="width:290px; height: 150px; padding: 5px;"> 
     <label class="checkbox-label"><input name="gai_max_V" id="gai_max_V" class="runoff" type="checkbox"><image src="icons/icona_land_use.png"/><p id="legend_text">Soil Runoff Capacity (1955)</p></input></label> 
     <div id="div-slider"> 
     <input type="range" name="slider-1" id="slider-1" value="80" min="20" max="100" step="20" data-highlight="true"> 
     </div> 
    <div style="width:290px; height: 150px; padding: 5px;">...</div> 
    <div style="width:290px; height: 150px; padding: 5px;">...</div> 
    </div> 
</div> 

jQuery Mobile的版本是1.4.5,地图,那是父DIV是由单张创建的内容:

var map = L.map('map', { 
    center: [45.81, 9.1], 
    zoom: 15 
}); 

你能猜到是为什么我无法移动手柄?

感谢,

Eylul

+0

这是最好的,你显示你所有相关的代码,例如:你怎么初始化滑块等... – iH8

+0

其实,这是它,我只是把它的HTML里面,然后附上一个事件监听器,但我认为它不相关。顺便说一下,感谢您检查问题:) –

+0

无法重现,您可以在这里看到:http://imgur.com/ZebN41a在Plunker上使用以下示例:http://embed.plnkr.co/oLMCHGlOOmzZWf1CclIh/ – iH8

回答

1

就可以解决这个问题的小CSS破解。

演示:https://jsfiddle.net/u2j24x25/2/

<!-- Insert this part after MAP --> 
<div id="div-slider"><input type="range" name="slider-1" id="slider-1" value="80" min="20" max="100" step="20" data-highlight="false"></div> 

/* CSS */ 
#map { height: 380px; } #div-slider {z-index:99999999;border:1px solid red;} #div-slider {position:relative;top:-250px;width:300px;float:right} 

编辑: 把DIV#传说后的div#地图将解决这个问题。

演示:https://jsfiddle.net/u2j24x25/4/

<div id="map" class="map" style="position: relative;"> 
</div> 

<div id="legend" class="legend" style="position: absolute; top: 0px; right: 0px; width:300px; z-index: 100;"> 
    <div style="width:290px; height: 150px; padding: 5px;"> 
     <label class="checkbox-label"> 
     <input name="gai_max_V" id="gai_max_V" class="runoff" type="checkbox"><image src="icons/icona_land_use.png"/><p id="legend_text">Soil Runoff Capacity (1955)</p></input></label> 
     <div id="div-slider"> 
     <input type="range" name="slider-1" id="slider-1" value="80" min="20" max="100" step="20" data-highlight="true"> 
     </div> 
    <div style="width:290px; height: 150px; padding: 5px;">...</div> 
    <div style="width:290px; height: 150px; padding: 5px;">...</div> 
    </div> 
</div> 

/* CSS */ 
#map { height: 380px; } 
+0

感谢您的回答。我看到把滑块外面的地图div工作。但是当我滚动图例时,我需要这个滑块与其他元素一起移动。最后,图例div中的每个图层都会有一个滑块。有没有办法做到这一点?谢谢! –

+0

尝试在关闭地图div后放置图例div。我将用新演示更新答案。 – clyz

+0

谢谢,这工作! 然后我也不得不删除这些行: L.DomEvent.disableClickPropagation(L.DomUtil.get('legend')); L.DomEvent.disableScrollPropagation(L.DomUtil.get('legend')); –