Created
February 27, 2012 03:04
-
-
Save adam-singer/1921030 to your computer and use it in GitHub Desktop.
Dispatch Event in Dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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