Skip to content

Instantly share code, notes, and snippets.

@mandado
Created July 1, 2013 15:13
Show Gist options
  • Save mandado/5901709 to your computer and use it in GitHub Desktop.
Save mandado/5901709 to your computer and use it in GitHub Desktop.
Estudando BackBone
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="jquery.js"></script>
<script src="lodash.js"></script>
<script src="backbone.js"></script>
</head>
<body>
<div id="app">
<input type="text" name="todoList" id="todoList" class="todoList"/>
</div>
<script>
var Fields = Backbone.Model.extend({
defaults: {
fieldName : ''
}
});
var FieldsCollection = Backbone.Collection.extend({
Model : Fields
})
var Field = new FieldsCollection([
new Fields({fieldName:'Jorge'}),
new Fields({fieldName:'Jorge1'}),
new Fields({fieldName:'Jorge2'}),
]);
var lista =Field.where({fieldName:'Jorge1'});
console.log(lista)
var App = Backbone.View.extend({
el: $('div#app'),
events: {
"keydown input.todoList": "addField"
},
addField: function (e) {
if (e.which === 9) {
e.preventDefault();
var html = '<input type="text" name="todoList" id="todoList" class="todoList"/>';
$('input.todoList', this.el).after(html)
}
}
})
var app = new App();
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment