我正在通過這篇文章http://blog.shinetech.com/2011/07/25/cascading-select-boxes-with-backbone-js/與backbone.js進行鏈接選擇,但在擴展類時遇到了錯誤。Backbone.js - Coffeescript延伸
所以,我有LocationsView類:
class Blog.Views.LocationsView extends Backbone.View
events:
"change": "changeSelected"
CountriesView類:
class Blog.Views.CountriesView extends Blog.Views.LocationsView
setSelectedId: (countryId) ->
CitiesView類:
class Blog.Views.CitiesView extends Blog.Views.LocationsView
setSelectedId: (cityId) ->
但當的CoffeeScript代碼編譯爲JavaScript我的擴展雙班容貌如:
(function() {
var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) {
for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; }
function ctor() { this.constructor = child; }
ctor.prototype = parent.prototype;
cities_view.js:5 Uncaught TypeError: Cannot read property 'prototype' of undefined
child.prototype = new ctor;
child.__super__ = parent.prototype;
return child;
};
Blog.Views.CitiesView = (function() {
__extends(CitiesView, Blog.Views.LocationsView);
function CitiesView() {
CitiesView.__super__.constructor.apply(this, arguments);
}
CitiesView.prototype.setSelectedId = function(cityId) {};
return CitiesView;
})();
}).call(this);
,我得到了錯誤:
Uncaught TypeError: Cannot read property 'prototype' of undefined cities_view.js:5
所以,這裏的問題是,如何解決?
你能提供完整的堆棧跟蹤嗎? – thejh