开发者

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;
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜