Class: Volt::UrlTracker
Overview
The URLTracker is responsible for updating the url when a param changes, or updating the url model/params when the browser url changes.
Instance Method Summary collapse
-
#initialize(volt_app) ⇒ UrlTracker
constructor
A new instance of UrlTracker.
- #url_updated(first_call = false) ⇒ Object
Constructor Details
#initialize(volt_app) ⇒ UrlTracker
Returns a new instance of UrlTracker.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/volt/page/url_tracker.rb', line 6 def initialize(volt_app) @volt_app = volt_app if Volt.client? that = self # Setup popstate on the dom ready event. Prevents an extra # popstate trigger ` window.addEventListener("popstate", function(e) { that.$url_updated(); return true; }); ` end end |
Instance Method Details
#url_updated(first_call = false) ⇒ Object
23 24 25 26 |
# File 'lib/volt/page/url_tracker.rb', line 23 def url_updated(first_call = false) @volt_app.url.parse(`document.location.href`) @volt_app.url.update! unless first_call end |