Skip to content

Instantly share code, notes, and snippets.

@quezo
Created June 6, 2012 21:56
Show Gist options
  • Save quezo/2885081 to your computer and use it in GitHub Desktop.
Save quezo/2885081 to your computer and use it in GitHub Desktop.
Backbone context management
<html>
<head>
</head>
<body>
<script src="jquery-1.7.1.js"></script>
<script src="handlebars.js"></script>
<script src="underscore.js"></script>
<script src="backbone.js"></script>
<script>
$(document).ready(function() {
queues = Backbone.View.extend({
className: "queues",
initialize: function() {
this.that = this;
this.that.id = "2";
console.log('id 2');
console.log(this.id);
that2 = 'wu style';
setTimeout(_.bind(function() {
console.log("aht 2: " + that2);
console.log('that 2');
console.log(this);
console.log(this.that.id);
}, this), 1000);
},
render: function() {
console.log('render queue');
}
});
q = new queues();
workers = Backbone.View.extend({
className: "workers",
initialize: function() {
this.that = this;
this.that.id = "1";
that1 = 'funky monkey';
console.log('id 1');
console.log(this.id);
setTimeout(_.bind(function() {
console.log("that1: " + that1);
console.log('that 1');
console.log(this);
console.log(this.that.id);
}, this), 1000);
},
render: function() {
console.log('render work');
}
});
w = new workers();
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment