Skip to content

Instantly share code, notes, and snippets.

@butlermatt
Created October 2, 2015 15:51
Show Gist options
  • Save butlermatt/10dbb29833c09ef0aec3 to your computer and use it in GitHub Desktop.
Save butlermatt/10dbb29833c09ef0aec3 to your computer and use it in GitHub Desktop.
MDL Dialog Observable Bug
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<link rel="stylesheet" href="packages/mdl/assets/styles/material.min.css">
</head>
<body>
<button class="mdl-button mdl-js-button mdl-button--raised" id="open">Open Dialog</button>
<script type="application/dart" src="main.dart"></script>
<script src="packages/browser/dart.js"></script>
</body>
</html>
import 'dart:html';
import 'package:mdl/mdl.dart';
import 'package:mdl/mdlobservable.dart';
import 'package:mdl/mdldialog.dart';
import 'package:di/di.dart' as di;
@MdlComponentModel @di.Injectable()
class ExampleDialog extends MaterialDialog {
ObservableProperty<String> text = new ObservableProperty<String>('');
ExampleDialog() : super(new DialogConfig());
ExampleDialog call() => this;
void onSubmit() {
close(MdlDialogStatus.OK);
}
@override
String template = '''
<div class="mdl-dialog">
<div class="mdl-dialog__content">
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
<input class="mdl-textfield__input" id="test" type="text" mdl-model="dialog.text" />
<label class="mdl-textfield__label" for="test">Message Here</label>
</div>
</div>
<div class="mdl-dialog__actions">
<button class="mdl-button mdl-js-button mdl-button--colorred" data-mdl-click="onSubmit()">
OK
</button>
</div>
</div>
''';
}
@MdlComponentModel @di.Injectable()
class Application extends MaterialApplication {
ExampleDialog dialog;
MaterialButton button;
Application() {
dialog = new ExampleDialog();
button = MaterialButton.widget(querySelector('#open'));
button.onClick.listen((_) {
dialog().show().then((status) { print(status);});
});
}
@override run(){
}
}
main() {
registerMdl();
componentFactory().rootContext(Application).run().then((MaterialApplication app) {
app.run();
});
}
name: mdl_dialog_bug
dependencies:
mdl: ^1.5.6
di: any
transformers:
- di
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment