From f8b122256fde859861553f441c3b63f3d35cfeb9 Mon Sep 17 00:00:00 2001 From: Aaron Parecki Date: Mon, 27 May 2019 11:22:01 -0400 Subject: wait for localforage callback before redirecting should help clear out the draft when a post is created. for #109 --- views/new-post.php | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'views') 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'); -- cgit v1.2.3