<!DOCTYPE html>
<html>
<head>
<title>Backbone.js Todo App</title>
<script src="jquery.js"></script>
<script src="underscore.js"></script>
<script src="backbone.js"></script>
</head>
<body>
<div > <img src="run.gif" height="100px"></div>
<div id="container"> <img src="run.gif"></div>
<script id="task_template" type="text/template">
<label> Todo </label>
<input id="task_desc" type="text"/>
<button> Add Task </button>
</script>
<script type="text/javascript">
Todo = Backbone.View.extend({
el: $('#container'),
initialize: function(){
this.render();
},
render: function(){
var template= _.template($('#task_template').html());
this.$el.html(template);
},
events:{
'click button' : 'fn_click'
},
fn_click: function(){
alert($('#task_desc').val());
}
});
var todo = new Todo();
</script>
</body>
</html>
<html>
<head>
<title>Backbone.js Todo App</title>
<script src="jquery.js"></script>
<script src="underscore.js"></script>
<script src="backbone.js"></script>
</head>
<body>
<div > <img src="run.gif" height="100px"></div>
<div id="container"> <img src="run.gif"></div>
<script id="task_template" type="text/template">
<label> Todo </label>
<input id="task_desc" type="text"/>
<button> Add Task </button>
</script>
<script type="text/javascript">
Todo = Backbone.View.extend({
el: $('#container'),
initialize: function(){
this.render();
},
render: function(){
var template= _.template($('#task_template').html());
this.$el.html(template);
},
events:{
'click button' : 'fn_click'
},
fn_click: function(){
alert($('#task_desc').val());
}
});
var todo = new Todo();
</script>
</body>
</html>