Skip to content

Instantly share code, notes, and snippets.

@d-adamkiewicz
Last active August 29, 2015 13:57
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 d-adamkiewicz/9832786 to your computer and use it in GitHub Desktop.
Save d-adamkiewicz/9832786 to your computer and use it in GitHub Desktop.
YUI3 event handling simple example
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>YUI Event example</title>
<script src="http://yui.yahooapis.com/3.15.0/build/yui/yui-min.js"></script>
<style typr="text/css">
#clickable {
cursor: pointer;
background: #cdcdcd;
width: 5em;
}
</style>
</head>
<body>
<div id="clickable">Click me</div>
<script>
YUI().use('event', function(Y) {
var clickable = Y.one('#clickable');
var Clickable = function(ev) {
var result = clickable.detach('click');
console.log(new Date().toString() + ' clicked!: ' + result);
clickable.on('dblclick', DblClickable);
},
DblClickable = function(ev) {
console.log('dblclicked: ' + clickable);
};
clickable.on('click', Clickable);
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment