From: Aaron Lidman Date: Wed, 13 Nov 2013 18:45:20 +0000 (-0800) Subject: Prevent empty search X-Git-Tag: live~4668^2~92 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/c5be2b6f8498ba4f0df1fc95f307078320e2b5be Prevent empty search --- diff --git a/app/assets/javascripts/index.js b/app/assets/javascripts/index.js index 2d397b812..f6cb02230 100644 --- a/app/assets/javascripts/index.js +++ b/app/assets/javascripts/index.js @@ -260,7 +260,12 @@ $(document).ready(function () { $(".search_form").on("submit", function(e) { e.preventDefault(); $("header").addClass("closed"); - OSM.route("/search?query=" + encodeURIComponent($(this).find("input[name=query]").val()) + OSM.formatHash(map)); + var query = $(this).find("input[name=query]").val(); + if (query) { + OSM.route("/search?query=" + encodeURIComponent(query) + OSM.formatHash(map)); + } else { + OSM.route("/" + OSM.formatHash(map)); + } }); $(".describe_location").on("click", function(e) {