Sha256: a01e8c2207fc9750c53718dc9cf663cf5bbbc1544d78226f5a6a365cadbb08cf
Contents?: true
Size: 797 Bytes
Versions: 23
Compression:
Stored size: 797 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
23 entries across 23 versions & 1 rubygems