From 2783877e869c7bfec30423f0a1e73bc33c269453 Mon Sep 17 00:00:00 2001 From: Alfredo Sumaran Date: Wed, 13 Apr 2016 10:54:51 -0500 Subject: Move declarations --- app/assets/javascripts/todos.js.coffee | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/todos.js.coffee b/app/assets/javascripts/todos.js.coffee index 37b4d2f66c7..08b29bd8214 100644 --- a/app/assets/javascripts/todos.js.coffee +++ b/app/assets/javascripts/todos.js.coffee @@ -73,14 +73,10 @@ class @Todos getTodosPerPage: -> @el.data('perPage') - redirectIfNeeded: (total) -> currPages = @getTotalPages() currPage = @getCurrentPage() - newPages = Math.ceil(total / @getTodosPerPage()) - url = location.href # Includes query strings - # Refresh if no remaining Todos if not total location.reload() @@ -89,6 +85,9 @@ class @Todos # Do nothing if no pagination return if not currPages + newPages = Math.ceil(total / @getTodosPerPage()) + url = location.href # Includes query strings + # If new total of pages is different than we have now if newPages isnt currPages # Redirect to previous page if there's one available -- cgit v1.2.1