2016-02-05 94 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')); –