diff --git a/docs/en/advanced/navigation-guards.md b/docs/en/advanced/navigation-guards.md
index 5217e958d..71b3d9a45 100644
--- a/docs/en/advanced/navigation-guards.md
+++ b/docs/en/advanced/navigation-guards.md
@@ -116,17 +116,19 @@ beforeRouteEnter (to, from, next) {
}
```
-Note that `beforeRouteEnter` is the only guard that supports passing a callback to `next`. For `beforeRouteUpdate` and `beforeRouteLeave`, `this` is already available, so passing a callback is unnecessary and therefore *not supported*:
-
```js
beforeRouteUpdate (to, from, next) {
- // just use `this`
+ // may use `this`
this.name = to.params.name
- next()
+
+ // may also pass a callback to next
+ next(vm => {
+ vm.name = to.params.name
+ })
}
```
-The **leave guard** is usually used to prevent the user from accidentally leaving the route with unsaved edits. The navigation can be canceled by calling `next(false)`.
+The **leave guard** is usually used to prevent the user from accidentally leaving the route with unsaved edits. The navigation can be canceled by calling `next(false)`. Note that `beforeRouteLeave` is the only guard that does not support passing a callback to `next`.
```js
beforeRouteLeave (to, from , next) {
diff --git a/examples/navigation-guards/app.js b/examples/navigation-guards/app.js
index 86f33c95e..d9ca3db7d 100644
--- a/examples/navigation-guards/app.js
+++ b/examples/navigation-guards/app.js
@@ -33,7 +33,7 @@ const Baz = {
},
template: `
+ `,
+ beforeRouteUpdate (to, from, next) {
+ // calls is incremented every time anything navigates, even if the
+ // navigation is canceled by a child component.
+ this.calls++
+
+ next(vm => {
+ // updates is only incremented once all children confirm and complete
+ // navigation. If any children load data async, then this will not be
+ // called until all children have called next() themselves. If any child
+ // cancels navigation, then this will never be called.
+ vm.updates++
+ })
+ }
+}
+
+// Buux implements a cancelable beforeRouteUpdate hook
+const Buux = {
+ data () {
+ return {
+ prevId: 0
+ }
+ },
+ template: `