             $el.find(".edit-wiki-content").remove()
 
         cancelEdition = ->
-            return if !$scope.wiki.html
-
-            if $scope.wiki.id
-                $scope.$apply () => $scope.wiki.revert()
-                switchToReadMode()
-            else
-                ctx = {project: $scope.projectSlug}
-                $location.path($navUrls.resolve("project-wiki", ctx))
+            return if not $model.$modelValue.id
+
+            $scope.$apply () =>
+                $model.$modelValue.revert()
+            switchToReadMode()
 
         getSelectedText = ->
             if $window.getSelection

    }

module.directive("tgEditableWikiContent", ["$window", "$document", "$tgRepo", "$tgConfirm", "$tgLoading",
                                           "$tgLocation", "$tgNavUrls", "$tgAnalytics", "$tgQqueue",
                                           EditableWikiContentDirective])

                if not wiki.id?
                    $analytics.trackEvent("wikipage", "create", "create wiki page", 1)

                $model.$modelValue = wikiPage
                $scope.$broadcast("wiki:edit", wikiPage)

                $confirm.notify("success")
                switchToReadMode()

            onError = ->
                $confirm.notify("error")
