-
-
Save jayd3e/2885106 to your computer and use it in GitHub Desktop.
Backbone context management
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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