尝试创建 Backbone.js 视图子类时出错
我有下面的backbone.js视图:
class MyApplication.Views.Cake extends Backbone.View
tagName: 'li'
className: 'cake'
和尝试的子类
class MyApplication.Views.AwesomeCake extends MyApplication.Views.Cake
但是在javascript控制台中,子类上抛出以下错误:
Uncaught TypeError: Cannot read property 'prototype' of undefined
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发现我的问题是 Rails 3.1 和资产管道的问题。由于 sprockets 按字母顺序加载 javascript 文件(并且因为 Awesome_cake 出现在 cake 之前),所以我需要需要超类文件。
问题中找到的解决方案:
Backbone.js - Coffeescript 扩展
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.
Solution found in question:
Backbone.js - Coffeescript extends