HashLocation
Ember.HashLocation Class
PRIVATE
Extends: Ember.Object
Defined in: packages/ember-routing/lib/location/hash_location.js:15
Module: ember-routing
Ember.HashLocation
implements the location API using the browser's hash. At present, it relies on a hashchange
event existing in the browser.
formatURL (url) private
Given a URL, formats it to be placed into the page as part of an element's href
attribute.
This is used, for example, when using the {{action}} helper to generate a URL based on an event.
Parameters:
-
url
String
getHashprivate
getURLprivate
Returns the normalized URL, constructed from location.hash
.
e.g. #/foo
=> /foo
as well as #/foo#bar
=> /foo#bar
.
By convention, hashed paths must begin with a forward slash, otherwise they are not treated as a path so we can distinguish intent.
onUpdateURL (callback) private
Register a callback to be invoked when the hash changes. These callbacks will execute when the user presses the back or forward button, but not after setURL
is invoked.
Parameters:
-
callback
Function
replaceURL (path) private
Uses location.replace to update the url without a page reload or history modification.
Parameters:
-
path
String
setURL (path) private
Set the location.hash
and remembers what was set. This prevents onUpdateURL
callbacks from triggering when the hash was set by HashLocation
.
Parameters:
-
path
String
willDestroyprivate
Cleans up the HashLocation event listener.
© 2017 Yehuda Katz, Tom Dale and Ember.js contributors
Licensed under the MIT License.
https://emberjs.com/api/classes/Ember.HashLocation.html