From b869090f787d96bb1869304c1ac41acd1e2dc3e4 Mon Sep 17 00:00:00 2001 From: Aaron Parecki Date: Mon, 20 Apr 2015 12:11:48 -0700 Subject: [PATCH] don't wipe out custom entry after the location-specific buttons load --- views/new-post.php | 21 +++++++++++++++++++++ views/partials/entry-buttons.php | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/views/new-post.php b/views/new-post.php index 1a64eb5..8767024 100644 --- a/views/new-post.php +++ b/views/new-post.php @@ -98,7 +98,28 @@ $(function(){ latitude: position.coords.latitude, longitude: position.coords.longitude }, function(response) { + // save and restore the value entered in the custom fields + var custom_eat = $('#custom_eat').val(); + var custom_drink = $('#custom_drink').val(); + + var selected = false; + if($("#custom_drink:focus").length == 1) { + selected = '#custom_drink'; + } + if($("#custom_eat:focus").length == 1) { + selected = '#custom_eat'; + } + $("#entry-buttons").html(response); + + // restore the custom values entered + $('#custom_eat').val(custom_eat); + $('#custom_drink').val(custom_drink); + + if(selected) { + $(selected).focus(); + } + bind_keyboard_shortcuts(); }); diff --git a/views/partials/entry-buttons.php b/views/partials/entry-buttons.php index a5e981f..fa46095 100644 --- a/views/partials/entry-buttons.php +++ b/views/partials/entry-buttons.php @@ -18,7 +18,7 @@ } if($type == 'drink' || $type == 'eat') { echo '
  • '; - echo ''; + echo ''; echo ''; echo '
    '; echo '
  • ';