agmcleod
agmcleod

Reputation: 13611

EmberJS Uncaught TypeError: Object [object Object] has no method 'create'

Trying to do some relatively basic client side setup with EmberJS with a small rails app. I have two things so far:

  1. A form to post a book for sale (not actually creating it yet)
  2. A search for books page. (Want this to be the home page as well).

The first one loads fine. When i click the link in the application template, the form loads as expected.

The second however does not. The subject error pops up when i click the link to view the search page. Here's the code i have so far:

<script type="text/x-handlebars">
  <div class="nav">
    {{#linkTo "index_search"}}Home{{/linkTo}}
    {{#linkTo sale_records.new}}Post a book for sale{{/linkTo}}
  </div>
  <div class="container">
    {{outlet}}
  </div>
</script>

Javascript:

// router.js
(function() {
  LocalBookFinder.Router.map(function() {
    this.resource("sale_records", { path: "/sale_records" }, function() {
      this.route('new');
    });
    this.route("index_search", { path: "/search" });
  });

  LocalBookFinder.NewSalesRecordRoute = Ember.Route.extend({
    model: function() {
      return new LocalBookFinder.SaleRecord();
    },
    setupController: function(controller, model) {

    }
  });

  LocalBookFinder.IndexSearchRoute = Ember.Route.extend({
    setupController: function(controller, model) {

    }
  });
}).call(this);

// controllers/search/index_search_controller.js
(function() {
  LocalBookFinder.IndexSearchController = Ember.ObjectController.extend({

  });
}).call(this);


// views/search/index_search_view.js

(function() {
  LocalBookFinder.IndexSearchView = Ember.View.create({
    templateName: "search/index"
  });
}).call(this);

The link itself renders fine. But once i click it, i get the error message, and nothing renders. Any ideas?

Upvotes: 2

Views: 2469

Answers (1)

Tom Brandt
Tom Brandt

Reputation: 56

There is an error where you set up IndexSearchView. It should be Ember.View.extend, not Ember.View.create.

Upvotes: 3

Related Questions