]> git.openstreetmap.org Git - rails.git/commitdiff
Prevent empty search
authorAaron Lidman <aaronlidman@gmail.com>
Wed, 13 Nov 2013 18:45:20 +0000 (10:45 -0800)
committerAaron Lidman <aaronlidman@gmail.com>
Wed, 13 Nov 2013 18:45:20 +0000 (10:45 -0800)
app/assets/javascripts/index.js

index 2d397b812840467e33994a05b2f816d7ada678dd..f6cb0223038c145e79852b6a0e84544d3fb9f84f 100644 (file)
@@ -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) {