0

I'm trying to create a Spine's Controller and init() it,

jQuery(function($) {
    window.Tests = Spine.Controller.create({
        init: function() {
            console.log('Tests created!');
        }
    });
    window.App = Tests.init();
});

but I have an error

Uncaught TypeError: Object function result() { return result.super.constructor.apply(this, arguments); } has no method 'init'

Spine is included before my Controller's file. Help me to solve it, why Controller.create() (and Controller.sub()) returns function and not an object?

I've tried to make it like in example:

jQuery(function($){
  window.App = Spine.Controller.create({
    el: $("body"),

    elements: {
      "#sidebar": "sidebarEl",
      "#contacts": "contactsEl"
    },

    init: function(){
      this.sidebar = Sidebar.init({el: this.sidebarEl});
      this.contact = Contacts.init({el: this.contactsEl});

      Contact.fetch();
    }
  }).init();
});
drzhbe
  • 785
  • 1
  • 6
  • 15

1 Answers1

0

I solved it by doing

new Tests();
drzhbe
  • 785
  • 1
  • 6
  • 15