Skip to content

Instantly share code, notes, and snippets.

@adam-singer
Created February 27, 2012 03:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adam-singer/1921030 to your computer and use it in GitHub Desktop.
Save adam-singer/1921030 to your computer and use it in GitHub Desktop.
Dispatch Event in Dart
#import('dart:html');
class dartEventsExample {
int counter = 0;
dartEventsExample() {
}
void run() {
document.query('#status').on.click.add((var event) {
write("Event ${++counter}");
});
Event e = new Event("click");
document.query('#status').on.click.dispatch(e);
}
void write(String message) {
// the HTML library defines a global "document" variable
document.query('#status').innerHTML = message;
}
}
void main() {
new dartEventsExample().run();
}
<html>
<head>
<title>dartEventsExample</title>
</head>
<body>
<h1>dartEventsExample</h1>
<h2 id="status">dart is not running</h2>
<script type="application/dart" src="dartEventsExample.dart"></script>
<script src="http://dart.googlecode.com/svn/branches/bleeding_edge/dart/client/dart.js"></script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment