PageRouter.PageInvocation Class
Created each time the url path changes and a page is run. The PageInvocation allows before filters to dynamically set the template, layout and nav, and provides methods for redirecting, stopping execution of the before filters and getting and setting page variables that will be cleaned up when a new page is run.
Instances are created automatically by the PageRouter when a path change
causes the router's run method to be called. The PageInvocation instance
is the value of this
in all before filters.
Constructor
PageRouter.PageInvocation
-
router
-
page
-
[context]
Parameters:
-
router
PageRouterA page router instance.
-
page
PageRouter.PageA page instance.
-
[context]
Object optionalAn optional context object.
Item Index
Methods
done
()
Don't run any additional before filters.
Example:
// inside a before filter
function filter () {
if (Meteor.loggingIn()) {
this.template("loggingIn");
this.done();
}
}
get
-
key
Gets a current invocation value.
Parameters:
-
key
StringThe key.
Returns:
Example:
// inside before filter
function filter () {
var post = this.get("post");
}
isDone
()
Boolean
Returns true if the invocation has been marked as done.
Returns:
isStopped
()
Boolean
Returns true if the invocation has been stopped.
Returns:
layout
-
[value]
Gets or sets the invocation's layout template name.
Parameters:
-
[value]
String optionalAn optional layout template name.
Returns:
redirect
-
path
-
[state]
Stops the current page and redirects to a new path.
Parameters:
-
path
StringThe path to redirect to.
-
[state]
Object optionalAn optional state object to pass along.
Example:
// before filter
function filter () {
this.redirect(Meteor.postIndexPath());
}
set
-
key
-
value
Set a page variable that can be accessed for the current invocation from
handlebars or downstream before filters. These will be cleared when a new
page is run (i.e. the url path changes). These values are accessible
using the page
Handlebars helper.
Parameters:
-
key
StringThe key. Example: "post".
-
value
AnyAny value.
Example:
// inside before filter
function filter () {
this.set("post", { _id: 1234 });
}
stop
()
Stops the current page run. Also stops pushState from being called. Call this to completely stop. No rendering, no more filters.
template
-
[value]
Gets or sets the invocation's template name.
Parameters:
-
[value]
String optionalAn optional template name.
Returns:
template
-
[value]
Gets or sets the invocation's nav key.
Parameters:
-
[value]
String optionalAn optional nav key.
Returns:
toObject
()
Object
Returns the invocation's dictionary. This is what is put into Session before the page is rendered.