Created
May 8, 2014 05:54
-
-
Save pushrax/87e771551ddbc4740f67 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
replaceCurrentRoute: (params) -> | |
params = Batman.extend({}, params) | |
# ... | |
currentPageParams = @routableParams(params) # loads some more data (controller and action) | |
# ... | |
path = Shopify.get('dispatcher').pathFromParams(currentPageParams) | |
return unless path | |
currentPath = Shopify.get('navigator')?.pathFromLocation(window.location) | |
@_navigate(currentPath, path) | |
params | |
_navigate: (currentPath, newPath) -> | |
currentPathWithoutQuery = currentPath?.split('?')[0] | |
newPathWithoutQuery = newPath?.split('?')[0] | |
if currentPathWithoutQuery == newPathWithoutQuery | |
Shopify.get('navigator')?.replaceState {}, null, newPath | |
else | |
Shopify.get('navigator')?.pushState {}, null, newPath |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment