javascript - Uncaught TypeError: Object prototype may only be an Object or null on ember-1.0.0-pre.2 - Stack Overflow

I am starting with Ember and just following this tutorial.I downloaded the last source from Ember.js

I am starting with Ember and just following this tutorial. I downloaded the last source from Ember.js web and I have the following code:

HTML

<!doctype html>
<html>
 <head>
   <script src="js/libs/jquery-1.7.2.min.js"></script>
   <script src="js/libs/ember-1.0.0-pre.2.min.js"></script>
   <script src="js/libs/handlebars-1.0.0.beta.6.js"></script>
   <script src="js/app.js"></script>
 </head>
 <script type="text/x-handlebars" data-template-name="application">
   Test
 </script>
</html>

app.js

   App = Em.Application.create();

   App.ApplicationView = Em.View.extend({
     templateName: 'application'
   });
   App.ApplicationController = Em.Controller.extend();


   App.Router = Em.Router.extend({
    root: Em.Route.extend({
      index: Em.Route.extend({
        route: '/'
      })
    })
  });

  App.initialize();

It seems a pretty simple example, but I fail to see these two things:

1) Why the source of ember gives me this error:

Uncaught TypeError: Object prototype may only be an Object or null 

On line 18 of the ember code.

2) Why I keep getting this uncaught error, if I have defined the template:

Uncaught Error: <App.ApplicationView:ember143> - Unable to find template "application". 

I am starting with Ember and just following this tutorial. I downloaded the last source from Ember.js web and I have the following code:

HTML

<!doctype html>
<html>
 <head>
   <script src="js/libs/jquery-1.7.2.min.js"></script>
   <script src="js/libs/ember-1.0.0-pre.2.min.js"></script>
   <script src="js/libs/handlebars-1.0.0.beta.6.js"></script>
   <script src="js/app.js"></script>
 </head>
 <script type="text/x-handlebars" data-template-name="application">
   Test
 </script>
</html>

app.js

   App = Em.Application.create();

   App.ApplicationView = Em.View.extend({
     templateName: 'application'
   });
   App.ApplicationController = Em.Controller.extend();


   App.Router = Em.Router.extend({
    root: Em.Route.extend({
      index: Em.Route.extend({
        route: '/'
      })
    })
  });

  App.initialize();

It seems a pretty simple example, but I fail to see these two things:

1) Why the source of ember gives me this error:

Uncaught TypeError: Object prototype may only be an Object or null 

On line 18 of the ember code.

2) Why I keep getting this uncaught error, if I have defined the template:

Uncaught Error: <App.ApplicationView:ember143> - Unable to find template "application". 
Share Improve this question edited Nov 11, 2012 at 17:16 Nobita asked Nov 11, 2012 at 17:10 NobitaNobita 23.7k11 gold badges63 silver badges87 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

Try putting the application template before handlebars.

<!doctype html>
<html>
 <head>
   <script type="text/x-handlebars" data-template-name="application">
     Test
   </script>
   <script src="js/libs/jquery-1.7.2.min.js"></script>
   <script src="js/libs/handlebars-1.0.0.beta.6.js"></script>
   <script src="js/libs/ember-1.0.0-pre.2.min.js"></script>
   <script src="js/app.js"></script>
 </head>
</html>

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742336521a4424760.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信