diff options
author | Aaron Parecki <aaron@parecki.com> | 2019-05-27 11:22:01 -0400 |
---|---|---|
committer | Aaron Parecki <aaron@parecki.com> | 2019-05-27 11:22:01 -0400 |
commit | f8b122256fde859861553f441c3b63f3d35cfeb9 (patch) | |
tree | 375a8d6e185b52284e2cc6ae28df265f84ba3e1f /views | |
parent | 3936347801fb784866565633538c9fd91fd24b73 (diff) |
wait for localforage callback before redirecting
should help clear out the draft when a post is created.
for #109
Diffstat (limited to 'views')
-rw-r--r-- | views/new-post.php | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/views/new-post.php b/views/new-post.php index 3455644..aba4129 100644 --- a/views/new-post.php +++ b/views/new-post.php @@ -815,16 +815,17 @@ $(function(){ if(typeof response == "string") { response = JSON.parse(response); } - localforage.removeItem('current-note'); - if(response.location) { - window.location = response.location; - // console.log(response.location); - } else { - $("#test_response").html(response.response); - $("#test_response_container").removeClass('hidden'); - $("#test_success").addClass('hidden'); - $("#test_error").removeClass('hidden'); - } + localforage.removeItem('current-note', function(){ + if(response.location) { + window.location = response.location; + // console.log(response.location); + } else { + $("#test_response").html(response.response); + $("#test_response_container").removeClass('hidden'); + $("#test_success").addClass('hidden'); + $("#test_error").removeClass('hidden'); + } + }); } catch(e) { $("#test_success").addClass('hidden'); $("#test_error").removeClass('hidden'); |