Skip to content

Instantly share code, notes, and snippets.

@plwalters
Forked from bcanzanella/app.html
Created October 23, 2016 14:02
Show Gist options
  • Save plwalters/b91df5edf408c688d7312c10366ecb81 to your computer and use it in GitHub Desktop.
Save plwalters/b91df5edf408c688d7312c10366ecb81 to your computer and use it in GitHub Desktop.
dialog not re-binding
<template>
<button click.delegate="prompt()">open dialog</button>
<br><br>
(app [inline]) inner data:<br>
<div repeat.for="s of outer.inner">${s.name}</div>
</template>
import {bindable} from 'aurelia-framework';
import {Prompt} from './prompt';
import {DialogService} from 'aurelia-dialog';
export class App {
@bindable outer;
static inject = [DialogService];
constructor(dialogService) {
this.dialogService = dialogService;
this.outer = {
inner: [{name:'first inner'},{name:'second inner' } ]
};
let self = this;
setTimeout(function() {
self.outer.inner = JSON.parse('[{"name":"replaced 1"},{"name":"replaced 2"}]');
},5000)
}
prompt() {
return this.dialogService.open({viewModel: Prompt, model: this.outer});
}
}
<!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 repeat.for="i of outer.inner">${i.name}</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 outer;
constructor(controller){
this.controller = controller;
}
activate(outer) {
this.outer = outer;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment