Skip to content

Instantly share code, notes, and snippets.

@bcanzanella
Last active October 23, 2016 13:08
Show Gist options
  • Save bcanzanella/36801eb2a5cd9059be3c34be492ee990 to your computer and use it in GitHub Desktop.
Save bcanzanella/36801eb2a5cd9059be3c34be492ee990 to your computer and use it in GitHub Desktop.
dialog not re-binding (with fooChanged)
<template>
<button click.delegate="prompt()">open dialog</button>
<br><br>
<div>${foo}</div>
</template>
import {bindable} from 'aurelia-framework';
import {Prompt} from './prompt';
import {DialogService} from 'aurelia-dialog';
export class App {
@bindable foo;
static inject = [DialogService];
constructor(dialogService) {
this.dialogService = dialogService;
this.foo ='started'
let me = this;
setTimeout(function() {
me.foo = 'replaced';
},10000)
}
prompt() {
return this.dialogService.open({viewModel: Prompt, model: this.foo});
}
}
<!doctype html>
<html>
<head>
<title>Aurelia</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body aurelia-app="main">
<h1>Loading...</h1>
<script src="https://cdn.rawgit.com/jdanyow/aurelia-bundle/v1.0.3/jspm_packages/system.js"></script>
<script src="https://cdn.rawgit.com/jdanyow/aurelia-bundle/v1.0.3/config.js"></script>
<script>
System.import('aurelia-bootstrapper');
</script>
</body>
</html>
export function configure(aurelia) {
aurelia.use
.standardConfiguration()
.developmentLogging()
.plugin('aurelia-dialog');
aurelia.start().then(() => aurelia.setRoot());
}
<template>
<ai-dialog>
<ai-dialog-body>
<div>${foo}</div>
</ai-dialog-body>
<ai-dialog-footer>
<button click.trigger="controller.cancel()">Cancel</button>
</ai-dialog-footer>
</ai-dialog>
</template>
import {DialogController} from 'aurelia-dialog';
import {bindable} from 'aurelia-framework';
export class Prompt {
static inject = [DialogController];
@bindable foo;
constructor(controller){
this.controller = controller;
}
activate(outer) {
this.foo = foo;
}
fooChanged(newValue) {
alert(newValue)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment