Roland
Roland

Reputation: 9701

Error in console when including the library

I'm starting on learning EmberJS and I see this error in the console :

Uncaught TypeError: Cannot call method 'proto' of undefined ember-1.0.pre.min.js:17

It seems that just by including the library I get that error. Does anyone have any idea why I get that ?

EDIT : Added HTML Markup

<!doctype html>

  <html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

    <title></title>
    <meta name="description" content="">
    <meta name="author" content="">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <link rel="shortcut icon" href="/favicon.ico">
    <link rel="apple-touch-icon" href="/apple-touch-icon.png">
    <link rel="stylesheet" href="css/style.css?v=2">

    <!--[if lt IE 9]>
    <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
  </head>
  <body>
    <script type="text/x-handlebars">
      {{#view App.MyView}}
        <h1>Hello world!</h1>
      {{/view}}
    </script>

    <!-- The missing protocol means that it will match the current protocol, either http or https. If running locally, we use the local jQuery. -->
    <script src="js/libs/jquery-1.7.2.min.js"></script>
    <script>window.jQuery || document.write('<script src="js/libs/jquery-1.7.2.min.js"><\/script>')</script>
  <script src="js/libs/handlebars-1.0.0.beta.6.js"></script>
  <script src="js/libs/ember-1.0.pre.js"></script>
  <script src="js/app.js"></script>
  </body>
  </html>

Also there's this JS in the app.js file :

var App = Em.Application.create();

App.MyView = Em.View.extend({
  mouseDown: function() {
  window.alert("hello world!");
}
});

but it has been removed and all the templating part from the HTML as well, and I still got the same error (:

Upvotes: 0

Views: 193

Answers (1)

Espo
Espo

Reputation: 41919

From the Ember Documentation:

Every Ember app should have an instance of Ember.Application. This object will serve as the globally-accessible namespace for all of the other classes and instances in your app

The key here is "global". Here's an example of an application:

window.App = Ember.Application.create();

Your problem is the var-keyword on your Application.create. Remove that and add Window to make the error disappear.

Upvotes: 1

Related Questions