mirror of
https://github.com/netzmacht/contao-leaflet-maps.git
synced 2025-11-30 12:03:44 +01:00
Prevent form submit on enter when using control geocoder and close popup when value is chosen.
This commit is contained in:
@@ -17,6 +17,12 @@
|
|||||||
placeholder: '<?php echo $GLOBALS['TL_LANG']['leaflet']['searchPosition']; ?>'
|
placeholder: '<?php echo $GLOBALS['TL_LANG']['leaflet']['searchPosition']; ?>'
|
||||||
}).addTo(map);
|
}).addTo(map);
|
||||||
|
|
||||||
|
document.querySelector('.leaflet-control-geocoder input').addEventListener('keydown', function (event) {
|
||||||
|
if (event.keyCode === 13) {
|
||||||
|
event.preventDefault();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
geocoder.on('markgeocode', function (event) {
|
geocoder.on('markgeocode', function (event) {
|
||||||
var container = document.createElement('div');
|
var container = document.createElement('div');
|
||||||
var link = document.createElement('button');
|
var link = document.createElement('button');
|
||||||
@@ -28,7 +34,8 @@
|
|||||||
e.stop();
|
e.stop();
|
||||||
|
|
||||||
element.set('value', result.center.lat + ',' + result.center.lng);
|
element.set('value', result.center.lat + ',' + result.center.lng);
|
||||||
});
|
this._geocodeMarker.closePopup();
|
||||||
|
}.bind(this));
|
||||||
|
|
||||||
container.appendHTML(result.html || result.name);
|
container.appendHTML(result.html || result.name);
|
||||||
container.appendChild(link);
|
container.appendChild(link);
|
||||||
|
|||||||
Reference in New Issue
Block a user