{"action":"created","issue":{"url":"https://api.github.com/repos/miguel-perez/smoothState.js/issues/247","repository_url":"https://api.github.com/repos/miguel-perez/smoothState.js","labels_url":"https://api.github.com/repos/miguel-perez/smoothState.js/issues/247/labels{/name}","comments_url":"https://api.github.com/repos/miguel-perez/smoothState.js/issues/247/comments","events_url":"https://api.github.com/repos/miguel-perez/smoothState.js/issues/247/events","html_url":"https://github.com/miguel-perez/smoothState.js/pull/247","id":131133580,"number":247,"title":"Allow onBefore calls to run on every page load","user":{"login":"mcaskill","id":29353,"avatar_url":"https://avatars.githubusercontent.com/u/29353?v=3","gravatar_id":"","url":"https://api.github.com/users/mcaskill","html_url":"https://github.com/mcaskill","followers_url":"https://api.github.com/users/mcaskill/followers","following_url":"https://api.github.com/users/mcaskill/following{/other_user}","gists_url":"https://api.github.com/users/mcaskill/gists{/gist_id}","starred_url":"https://api.github.com/users/mcaskill/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mcaskill/subscriptions","organizations_url":"https://api.github.com/users/mcaskill/orgs","repos_url":"https://api.github.com/users/mcaskill/repos","events_url":"https://api.github.com/users/mcaskill/events{/privacy}","received_events_url":"https://api.github.com/users/mcaskill/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-02-03T19:50:04Z","updated_at":"2016-02-08T01:51:51Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/miguel-perez/smoothState.js/pulls/247","html_url":"https://github.com/miguel-perez/smoothState.js/pull/247","diff_url":"https://github.com/miguel-perez/smoothState.js/pull/247.diff","patch_url":"https://github.com/miguel-perez/smoothState.js/pull/247.patch"},"body":"Resolves #219\r\n\r\nThe only missing feature for is a way to store the `$trigger` within the pushed state so as to be able to use it as the `$currentTarget` in the `onBefore()` function when `onPopState()` is called.\r\n\r\nCurrently with this change, any custom `onBefore()` declarations need to test for `$currentTarget` or suffer an error.\r\n\r\nIf this PR is accepted, please update the demos in your 'master' branch so as to reduce the differences."},"comment":{"url":"https://api.github.com/repos/miguel-perez/smoothState.js/issues/comments/181158680","html_url":"https://github.com/miguel-perez/smoothState.js/pull/247#issuecomment-181158680","issue_url":"https://api.github.com/repos/miguel-perez/smoothState.js/issues/247","id":181158680,"user":{"login":"mcaskill","id":29353,"avatar_url":"https://avatars.githubusercontent.com/u/29353?v=3","gravatar_id":"","url":"https://api.github.com/users/mcaskill","html_url":"https://github.com/mcaskill","followers_url":"https://api.github.com/users/mcaskill/followers","following_url":"https://api.github.com/users/mcaskill/following{/other_user}","gists_url":"https://api.github.com/users/mcaskill/gists{/gist_id}","starred_url":"https://api.github.com/users/mcaskill/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mcaskill/subscriptions","organizations_url":"https://api.github.com/users/mcaskill/orgs","repos_url":"https://api.github.com/users/mcaskill/repos","events_url":"https://api.github.com/users/mcaskill/events{/privacy}","received_events_url":"https://api.github.com/users/mcaskill/received_events","type":"User","site_admin":false},"created_at":"2016-02-08T01:51:51Z","updated_at":"2016-02-08T01:51:51Z","body":"Good point. The project I'm working on also has a header area (outside of SmoothState's container) and we are having to deal with unbinding events when changing pages (I've arrived after much of the integration has been completed). Currently, our unbinding occurs in the `onStart()` handler but only for one particular page (the other pages haven't had unbinding implemented yet). Also, caching hasn't been activated so I am not aware of issues between `fetch()` and `onStart()`.\r\n\r\nSo basically, the `onBefore()` handler is used by `clickAnchor()` and `submitForm()`; maybe that handler should be renamed `onAction($currentTarget, $container)`; then add an `onBefore(request, $container)` early on in the `load()` function, before it calls `fetch()`.\r\n\r\nThis would probably help with the confusion of `onBefore`'s naming and would trigger with `onPopState`.\r\n"}}