[英]Close popup and then open another vs. opening popup while another one is open
我想用justGage庫在我的傳單彈出窗口中顯示一個量規。 當我打開一個彈出窗口時,或者當我關閉一個彈出窗口並打開另一個彈出窗口時,它工作正常,但是如果打開了一個彈出窗口,則單擊另一個標記,第一個彈出窗口會按其應做的方式關閉,第二個彈出窗口打開,但是儀表不展示。
這就是我生成彈出窗口的方式:
var myLayer = new L.GeoJSON.AJAX("data/data.geojson", {
onEachFeature: function(feature, layer) {
layer.bindPopup(function (layer) {
$('#myDiv').text();
});
}
});
myDiv是彈出窗口的內容:
<script id="myDiv" type="text/template">
<div>
<div id='gauge1' style='width:60px; height:80px'></div>
</div>
<div>
<div id='gauge2' style='width:60px; height:80px'></div>
</div>
</script>
當彈出窗口打開時,我會初始化儀表(這是我讓它們工作的唯一方法):
myMarkers.on('popupopen', function(e) {
cargaVelocimetro("gauge1", 22);
cargaVelocimetro("gauge2", 33);
}
);
function cargaVelocimetro(id, valor){
if (!gauge) {
var gauge = new JustGage({
id: id,
value: valor,
min: 0,
max: 100,
gaugeWidthScale: 0.8
});
}
}
這就像未正確關閉第一個彈出窗口以某種方式影響傳單的事實?
正如巴蒂斯特(Baptiste)在評論中說的那樣,如果第二個彈出窗口仍處於打開狀態,則在打開第二個彈出窗口時ID會混淆在一起。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.