document new argument in m.route(path)
This commit is contained in:
parent
2b8c82e365
commit
bdcfbde8e0
5 changed files with 19 additions and 12 deletions
|
|
@ -5,6 +5,8 @@
|
|||
### News:
|
||||
|
||||
- The signature of `m` now accepts virtual elements as the second parameter of the function.
|
||||
- `m.route(path, params)` now accepts an argument that gets parsed as a querystring.
|
||||
- routes now ignore trailing slashes [#88](https://github.com/lhorie/mithril.js/issues/88)
|
||||
|
||||
### Bug Fixes:
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@
|
|||
<li><a href="mithril.route.html">m.route</a>
|
||||
<ul>
|
||||
<li><a href="mithril.route.html#defining-routes">m.route(rootElement, defaultRoute, routes)</a></li>
|
||||
<li><a href="mithril.route.html#redirecting">m.route(path)</a></li>
|
||||
<li><a href="mithril.route.html#redirecting">m.route(path, params)</a></li>
|
||||
<li><a href="mithril.route.html#reading-current-route">m.route()</a></li>
|
||||
<li><a href="mithril.route.html#mode-abstraction">m.route(element)</a></li>
|
||||
<li><a href="mithril.route.html#mode">m.route.mode</a></li>
|
||||
|
|
|
|||
|
|
@ -264,13 +264,17 @@ redirects to `http://server/#/dashboard/marysue`
|
|||
[How to read signatures](how-to-read-signatures.md)
|
||||
|
||||
```clike
|
||||
void route(String path)
|
||||
void route(String path [, any params])
|
||||
```
|
||||
|
||||
- **String path**
|
||||
|
||||
The route to redirect to. Note that to redirect to a different page outside of the scope of Mithril's routing, you should use `window.location`
|
||||
|
||||
- **any params**
|
||||
|
||||
Parameters to pass as a querystring
|
||||
|
||||
---
|
||||
|
||||
<a name="reading-current-route"></a>
|
||||
|
|
|
|||
14
mithril.d.ts
vendored
14
mithril.d.ts
vendored
|
|
@ -6,13 +6,13 @@ interface MithrilStatic {
|
|||
prop(value?: any): (value?: any) => any;
|
||||
withAttr(property: string, callback: (value: any) => void): (e: Event) => any;
|
||||
module(rootElement: Element, module: MithrilModule): void;
|
||||
trust(html: string): String
|
||||
render(rootElement: Element, children?: any): void
|
||||
render(rootElement: HTMLDocument, children?: any): void
|
||||
redraw(): void
|
||||
route(rootElement: Element, defaultRoute: string, routes: { [key: string]: MithrilModule }): void
|
||||
route(rootElement: HTMLDocument, defaultRoute: string, routes: { [key: string]: MithrilModule }): void
|
||||
route(path: string): void
|
||||
trust(html: string): String;
|
||||
render(rootElement: Element, children?: any): void;
|
||||
render(rootElement: HTMLDocument, children?: any): void;
|
||||
redraw(): void;
|
||||
route(rootElement: Element, defaultRoute: string, routes: { [key: string]: MithrilModule }): void;
|
||||
route(rootElement: HTMLDocument, defaultRoute: string, routes: { [key: string]: MithrilModule }): void;
|
||||
route(path: string, params?: any, shouldReplaceHistory?: boolean): void;
|
||||
route(): string;
|
||||
route(element: Element, isInitialized: boolean): void;
|
||||
request(options: MithrilXHROptions): MithrilPromise;
|
||||
|
|
|
|||
|
|
@ -298,9 +298,10 @@ Mithril = m = new function app(window) {
|
|||
}
|
||||
else if (typeof arguments[0] == "string") {
|
||||
currentRoute = arguments[0]
|
||||
var shouldReplaceHistoryEntry = arguments[1] === true
|
||||
var queryString = typeof arguments[1] == "object" ? buildQueryString(arguments[1]) : null
|
||||
if(queryString) currentRoute += (currentRoute.indexOf('?') === -1 ? '?' : '&') + queryString
|
||||
var querystring = typeof arguments[1] == "object" ? buildQueryString(arguments[1]) : null
|
||||
if (querystring) currentRoute += (currentRoute.indexOf("?") === -1 ? "?" : "&") + querystring
|
||||
|
||||
var shouldReplaceHistoryEntry = (arguments.length == 3 ? arguments[2] : arguments[1]) === true
|
||||
|
||||
if (window.history.pushState) {
|
||||
computePostRedrawHook = function() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue