Sha256: d02fe2ce76b77b20188c2d7b8ba49538b6ffd7161bf6e3bd0f945eeb890dc11b
Contents?: true
Size: 826 Bytes
Versions: 55
Compression:
Stored size: 826 Bytes
Contents
# The URLTracker is responsible for updating the url when # a param changes, or updating the url model/params when # the browser url changes. class UrlTracker def initialize(page) @page = page if Volt.client? page.params.on('child_changed') do @page.url.update! end that = self # Setup popstate on the dom ready event. Prevents an extra # popstate trigger %x{ var first = true; window.addEventListener("popstate", function(e) { if (first === false) { that.$url_updated(); } first = false; return true; }); } end end def url_updated(first_call=false) @page.url.parse(`document.location.href`) @page.url.update! unless first_call end end
Version data entries
55 entries across 55 versions & 1 rubygems