Commit fd8c7eb24a77e578ad5db952b21e21a1977ab6cf:
get the server working again (part 1?)
Branch: refs/heads/master
Author: Sam Ruby <[email protected]>
Committer: Sam Ruby <[email protected]>
Pusher: rubys <[email protected]>
------------------------------------------------------------
views/main.js.rb | +++++ ----
------------------------------------------------------------
18 changes: 10 additions, 8 deletions.
------------------------------------------------------------
diff --git a/views/main.js.rb b/views/main.js.rb
index 14a51a5..0b4b05a 100644
--- a/views/main.js.rb
+++ b/views/main.js.rb
@@ -8,10 +8,6 @@ def initialize
def componentWillMount()
Main.navigate = self.navigate
self.navigate(@@path, true)
-
- window.addEventListener :popstate do |event|
- self.navigate(event.state.path, true)
- end
end
def navigate(path, replace)
@@ -21,10 +17,12 @@ def navigate(path, replace)
item = Agenda
end
- if replace
- history.replaceState({path: path}, nil, path)
- else
- history.pushState({path: path}, nil, path)
+ if defined? history
+ if replace
+ history.replaceState({path: path}, nil, path)
+ else
+ history.pushState({path: path}, nil, path)
+ end
end
@item = item
@@ -57,6 +55,10 @@ def render
end
def componentDidMount()
+ window.addEventListener :popstate do |event|
+ self.navigate(event.state.path, true)
+ end
+
def window.onresize()
main = document.querySelector('main')
header = document.querySelector('header.navbar')