PjaxBase Class
yui3/src/pjax/js/pjax-base.js:43
Parent Module: pjax
Available since 3.5.0
Y.Router
extension that provides the core plumbing for enhanced navigation
implemented using the pjax technique (HTML5 pushState
+ Ajax).
This makes it easy to enhance the navigation between the URLs of an application in HTML5 history capable browsers by delegating to the router to fulfill the "request" and seamlessly falling-back to using standard full-page reloads in older, less-capable browsers.
The PjaxBase
class isn't useful on its own, but can be mixed into a
Router
-based class to add Pjax functionality to that Router. For a pre-made
standalone Pjax router, see the Pjax
class.
var MyRouter = Y.Base.create('myRouter', Y.Router, [Y.PjaxBase], {
// ...
});
Index
Properties
Attributes
Events
Methods
_isLinkSameOrigin
-
link
Utility method to test whether a specified link/anchor node's href
is of
the same origin as the page's current location.
This normalize browser inconsistencies with how the port
is reported for
anchor elements (IE reports a value for the default port, e.g. "80").
Parameters:
-
link
Node<p><p>The anchor element to test whether its <code>href</code> is of the same origin as the page's current location.</p></p>
Returns:
<p><p>Whether or not the link's <code>href</code> is of the same origin as the page's current location.</p></p>
_onLinkClick
-
e
Handler for delegated link-click events which match the linkSelector
.
This will attempt to enhance the navigation to the link element's href
by
passing the URL to the _navigate()
method. When the navigation is being
enhanced, the default action is prevented.
If the user clicks a link with the middle/right mouse buttons, or is holding down the Ctrl or Command keys, this method's behavior is not applied and allows the native behavior to occur. Similarly, if the router is not capable or handling the URL because no route-handlers match, the link click will behave natively.
Parameters:
_pjaxBindUI
()
protected
Binds the delegation of link-click events that match the linkSelector
to
the _onLinkClick()
handler.
By default this method will only be called if the browser is capable of using HTML5 history.
Properties
Attributes
allowFallThrough
Boolean
Whether to set window.location
when calling navigate()
if no routes match the specified URL.
Default: true
linkSelector
String | Function
CSS selector string used to filter link click events so that only the links which match it will have the enhanced navigation behavior of Pjax applied.
When a link is clicked and that link matches this selector, Pjax will
attempt to dispatch to any route handlers matching the link's href
URL. If
HTML5 history is not supported or if no route handlers match, the link click
will be handled by the browser just like any old link.
Default: "a.yui3-pjax"