1
我想用提交按鈕在我的數據庫彈出窗口中發送一個表單,但是如果點擊我創建的每個標記的提交按鈕,沒有任何反應與Leaflet.draw插件。這裏是我的代碼:提交表單內的彈出窗口不返回結果
map.on('draw:created', function (e){
var type = e.layerType;
layer = e.layer;
var y = layer.getLatLng().lat;
var x = layer.getLatLng().lng;
var Marker = drawnItems.addLayer(layer);
Marker.on('click', function (e){
var popupContent = '<form role="form" id="form" enctype="multipart/form-data" class ="form-horizontal" >'+
'<div class="form-group">'+
'<label>Adresse <input type="text" name="text" id="text"></label>' + '<br/>' +
'<button type="button" class="btn btn-warning" id="submit">Add</button>'+
'</div>' +
'</form>';
var popup = L.popup()
.setLatLng(e.latlng)
.setContent(popupContent)
.openOn(map);
map.addLayer(layer);
});
$('#form').submit(function(event) {
event.preventDefault();
console.log("submit worked!");
var text = $('#text').val();
});
});
謝謝,成功了! – lazzat