Backbone unable to start?
I'm getting started with backbone.js... but couldn't get it to work at all.
<script src="L开发者_如何转开发ibraries/jquery.min.js"></script>
<script src="Libraries/backbone.js"></script><script src="Libraries/Underscore.js"></script>
<script>
$(function(){
window.Todo = Backbone.Model.extend({
});
});
</script>
And on Chrome, the error log says: Cannot call method 'extend' of undefined..and was initiated by Backbone.Model.extend...why? thanks
You need to load Underscore first, as Backbone is dependent on it (you can't drive your car without the engine) - try:
<script src="Libraries/jquery.min.js"></script>
<script src="Libraries/Underscore.js"></script>
<script src="Libraries/backbone.js"></script>
also, just to be safe, put everything in a window "on load" function to make sure everything is loaded -
$(document).ready(function() {
// Stuff to do as soon as the DOM is ready;
});
精彩评论