Skip to content

Instantly share code, notes, and snippets.

@gnuwilliam
Created March 16, 2014 07:03
Show Gist options
  • Save gnuwilliam/9579555 to your computer and use it in GitHub Desktop.
Save gnuwilliam/9579555 to your computer and use it in GitHub Desktop.
Simple Dart helper class to add new button elements
class DartBtn {
ButtonElement addButton(id, text, btnClass, container) {
var button = new ButtonElement();
button..id = id
..text = text
..classes.add(btnClass);
querySelector(container).children.add(button);
return button;
}
}
@gnuwilliam
Copy link
Author

Usage example

DartBtn btn1 = new DartBtn();
btn1.addButton(
    'alert', 
    'Display alert!', 
    'btn', 
    '#main'
)..onClick.listen((e) => window.alert('Confirmed!'));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment