Jquery 动态加载内容时,传单弹出窗口未对齐
在动态加载内容时,我遇到了弹出窗口未对齐的问题,如以下JSFIDLE: 使用传单0.7.2:Jquery 动态加载内容时,传单弹出窗口未对齐,jquery,css,popup,alignment,leaflet,Jquery,Css,Popup,Alignment,Leaflet,在动态加载内容时,我遇到了弹出窗口未对齐的问题,如以下JSFIDLE: 使用传单0.7.2: var new_marker = L.marker([lat, lon]) .bindPopup("<div id='popupcontent'></div>", {maxWidth: 500, maxHeight: 300}) .on('click', function(e){ $.post("updatecontent.
var new_marker = L.marker([lat, lon])
.bindPopup("<div id='popupcontent'></div>", {maxWidth: 500, maxHeight: 300})
.on('click', function(e){
$.post("updatecontent.php", {lat: lat, lon: lon},
function(data) {
$('#popupcontent').html(data);
});
});
map.addLayer(new_marker, true);
但是当弹出窗口打开时,它会移动
有什么想法吗?谢谢:)设置好弹出窗口的内容后,您应该将弹出窗口绑定到标记上
var popup = new L.Popup();
marker.addTo(map);
marker.on('click', function(e) {
popup.setContent('Hello world');
marker.bindPopup(popup);
marker.openPopup();
});
要对齐弹出文本,请执行以下操作
marker.bindPopup('<div id="popupcontent" class="centerClass"></div>');
是的,但这不是动态加载内容。我需要将$.post请求的结果设置到弹出窗口中。只需将setContent、bindpoppup、openPopup放在$.post的回调中即可。
marker.bindPopup('<div id="popupcontent" class="centerClass"></div>');
.centerClass{
text-align: center;
}