Created
July 14, 2014 08:58
-
-
Save mdaisuke/94d44250b05b3b654681 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<!-- download jquery, underscore, and backbone library --> | |
<html> | |
<head> | |
<title>hoge</title> | |
</head> | |
<body> | |
<script type="text/javascript" src="jquery-1.11.1.min.js"></script> | |
<script type="text/javascript" src="underscore-min.js"></script> | |
<script type="text/javascript" src="backbone-min.js"></script> | |
<script charset="utf-8" type="text/javascript"> | |
var MyView = Backbone.View.extend({ | |
el: "#foo", | |
events: { | |
"click": "click", | |
"click .bar": "clickBar", | |
"click .baz": "clickBaz" | |
}, | |
initialize: function() { | |
this.render(); | |
}, | |
click: function(e) {console.log("click");}, | |
clickBar: function(e) {console.log("clickBar");}, | |
clickBaz: function(e) {console.log("clickBaz");}, | |
render: function(){ | |
$(this.el).append('<span class="hoge">hoge</span>') | |
} | |
}); | |
$(document).ready(function(){ | |
new MyView(); | |
}); | |
</script> | |
<h1>hoge</h1> | |
<div id="foo"> | |
<span class="bar">bar</span> | |
<span class="baz">baz</span> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment