-
-
Save TonyLugg/f4a7fa39c9d82f5de0af3b0bc8e01850 to your computer and use it in GitHub Desktop.
canDeactivate Issue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<style> | |
ul { margin-bottom: 20px; } | |
</style> | |
<h1>Navigation Back Cancelation Test</h1> | |
<ul> | |
<li>Click the Next Page button to navigate to the next page.</li> | |
<li>Click the Back wtih Cancel button. Notice the navigation is stopped by canDeactivate().</li> | |
<li>Click the Back wtih Cancel button again. Navigation is NOT stopped, which is wrong.</li> | |
</ul> | |
<router-view></router-view> | |
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Router, RouterConfiguration } from 'aurelia-router'; | |
export class App { | |
configureRouter(config, router) { | |
this.router = router; | |
config.title = 'canDeactivate Issue'; | |
config.map([ | |
{ route: ['', 'home'], name: 'home', moduleId: 'home' }, | |
{ route: 'nextpage', name: 'nextpage', moduleId: 'nextpage' } | |
]); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<h4>Home</h4> | |
<div> | |
<button click.trigger="btnNext_click()">Next Page</button> | |
</div> | |
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Router } from 'aurelia-router'; | |
import { inject } from 'aurelia-framework' | |
@inject(Router) | |
export class Home { | |
constructor(router) { | |
this.router = router; | |
} | |
btnNext_click() { | |
this.router.navigate('nextpage'); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<title>Aurelia</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
</head> | |
<body aurelia-app> | |
<h1>Loading...</h1> | |
<script src="https://jdanyow.github.io/rjs-bundle/node_modules/requirejs/require.js"></script> | |
<script src="https://jdanyow.github.io/rjs-bundle/config.js"></script> | |
<script src="https://jdanyow.github.io/rjs-bundle/bundles/aurelia.js"></script> | |
<script src="https://jdanyow.github.io/rjs-bundle/bundles/babel.js"></script> | |
<script> | |
require(['aurelia-bootstrapper']); | |
</script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<h4>Next Page</h4> | |
<div> | |
<button click.trigger="btnBackWithCancel_click()">Back with Cancel</button> | |
<button click.trigger="btnBackWithProceed_click()">Back with Proceed</button> | |
</div> | |
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Router } from 'aurelia-router'; | |
import { inject } from 'aurelia-framework' | |
@inject(Router) | |
export class Nextpage { | |
cancelContinue = false; | |
constructor(router) { | |
this.router = router; | |
} | |
btnBackWithCancel_click() { | |
this.cancelContinue = false; | |
this.router.navigateBack(); | |
} | |
btnBackWithProceed_click() { | |
this.cancelContinue = true; | |
this.router.navigateBack(); | |
} | |
canDeactivate() { | |
return this.cancelContinue; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment