Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<meta name=”description” content=”Backbone.js tutorial code sample”>  
<link rel=”author” href=”https://plus.google.com/u/0/+ArvindRavulavaru“/>
<title>Backbone.js Tutorial - Arvind Ravulavaru</title>
  
</head>
<body>
  <!-- Model.set() sets a hash containing one or more attributes on the model. When any of these attributes alter the state of the model, a change event is triggered on it. Change events for each attribute are also triggered and can be bound to (e.g. change:name, change:age) -->
  
  <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
  <script type="text/javascript" src="http://documentcloud.github.com/underscore/underscore-min.js"></script>
  <script type="text/javascript" src="http://documentcloud.github.com/backbone/backbone-min.js"></script>  
</body>
</html>
 
var Todo = Backbone.Model.extend({
  defaults: {
    title: '',
    completed: false
  }
});
var myTodo = new Todo({
  title: "Set through instantiation."
});
console.log('Todo title: ' + myTodo.get('title')); 
console.log('Completed: ' + myTodo.get('completed')); 
myTodo.set({"title": "Title attribute set through Model.set()."});
console.log('Todo title: ' + myTodo.get('title'));
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
arvindr21pro
0viewers