From: Anton Khorev Date: Tue, 31 Dec 2024 20:07:49 +0000 (+0300) Subject: Pass text instead of form to createNote() X-Git-Tag: live~442^2~14 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/63a4f12550012991fcc8e26acbd0167f1ca9d48e?ds=inline Pass text instead of form to createNote() --- diff --git a/app/assets/javascripts/index/new_note.js b/app/assets/javascripts/index/new_note.js index 7a82c5bc6..e5d365589 100644 --- a/app/assets/javascripts/index/new_note.js +++ b/app/assets/javascripts/index/new_note.js @@ -35,7 +35,7 @@ OSM.NewNote = function (map) { OSM.router.route("/note/new"); }); - function createNote(marker, form, url) { + function createNote(marker, text, url) { var location = marker.getLatLng().wrap(); marker.options.draggable = false; @@ -48,7 +48,7 @@ OSM.NewNote = function (map) { data: { lat: location.lat, lon: location.lng, - text: $(form.text).val() + text }, success: function (feature) { noteCreated(feature, marker); @@ -150,9 +150,11 @@ OSM.NewNote = function (map) { } content.find("input[type=submit]").on("click", function (e) { + const text = content.find("textarea").val(); + e.preventDefault(); $(this).prop("disabled", true); - createNote(newNoteMarker, e.target.form, "/api/0.6/notes.json"); + createNote(newNoteMarker, text, "/api/0.6/notes.json"); }); return map.getState();