From 9d8ca8be11b6a529eb352064b1ea9a3975c4e065 Mon Sep 17 00:00:00 2001 From: Anton Khorev Date: Tue, 31 Dec 2024 23:42:40 +0300 Subject: [PATCH] Pass location instead of marker to createNote() --- app/assets/javascripts/index/new_note.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) 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); -- 2.39.5