1

I have the backbone.js view below:

class MyApplication.Views.Cake extends Backbone.View
    tagName: 'li'
    className: 'cake'

and the attempted subclass

class MyApplication.Views.AwesomeCake extends MyApplication.Views.Cake

However in the javascript console the following error is thrown on the subclass:

Uncaught TypeError: Cannot read property 'prototype' of undefined
jwarzech
  • 6,596
  • 11
  • 52
  • 72

1 Answers1

4

I found out that my issue was a problem with Rails 3.1 and the asset pipeline. Since sprockets loads the javascript files in alphabetical order (and because awesome_cake comes before cake) I needed to require the superclasses file.

#= require ./cake
class MyApplication.Views.AwesomeCake extends MyApplication.Views.Cake

Solution found in question: Backbone.js - Coffeescript extends

Community
  • 1
  • 1
jwarzech
  • 6,596
  • 11
  • 52
  • 72