From: Anton Khorev Date: Tue, 31 Dec 2024 20:42:40 +0000 (+0300) Subject: Pass location instead of marker to createNote() X-Git-Tag: live~53^2~11 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/9d8ca8be11b6a529eb352064b1ea9a3975c4e065 Pass location instead of marker to createNote() --- diff --git a/app/assets/javascripts/index/new_note.js b/app/assets/javascripts/index/new_note.js index f50357158..a3b809d0d 100644 --- a/app/assets/javascripts/index/new_note.js +++ b/app/assets/javascripts/index/new_note.js @@ -35,12 +35,7 @@ OSM.NewNote = function (map) { OSM.router.route("/note/new"); }); - function createNote(marker, text, callback) { - var location = marker.getLatLng().wrap(); - - marker.options.draggable = false; - marker.dragging.disable(); - + function createNote(location, text, callback) { $.ajax({ url: "/api/0.6/notes.json", type: "POST", @@ -139,11 +134,15 @@ OSM.NewNote = function (map) { } content.find("input[type=submit]").on("click", function (e) { + const location = newNoteMarker.getLatLng().wrap(); const text = content.find("textarea").val(); e.preventDefault(); $(this).prop("disabled", true); - createNote(newNoteMarker, text, (feature) => { + newNoteMarker.options.draggable = false; + newNoteMarker.dragging.disable(); + + createNote(location, text, (feature) => { content.find("textarea").val(""); updateMarker(feature); noteLayer.removeLayer(newNoteMarker);