Skip to content

Instantly share code, notes, and snippets.

@jayd3e
Forked from quezo/Backbone.html
Created June 6, 2012 22:01
Show Gist options
  • Save jayd3e/2885106 to your computer and use it in GitHub Desktop.
Save jayd3e/2885106 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() {
that = this;
that.id = "2";
console.log('id 2');
setTimeout(function() {
console.log('that 2');
console.log(this);
console.log(that.id);
}, 1000);
},
render: function() {
console.log('render queue');
}
});
q = new queues();
workers = Backbone.View.extend({
className: "workers",
initialize: function() {
that = this;
that.id = "1"
console.log(this.id);
setTimeout(function() {
console.log('that 1');
console.log(this);
console.log(that.id);
}, 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