Tôi đang tạo chuỗi lựa chọn với backbone.js theo bài viết này http://blog.shinetech.com/2011/07/25/cascading-select-boxes-with-backbone-js/, nhưng có lỗi, khi mở rộng lớp học.Backbone.js - Coffeescript mở rộng
Vì vậy, tôi có lớp LocationsView:
class Blog.Views.LocationsView extends Backbone.View
events:
"change": "changeSelected"
lớp CountriesView:
class Blog.Views.CountriesView extends Blog.Views.LocationsView
setSelectedId: (countryId) ->
CitiesView lớp:
class Blog.Views.CitiesView extends Blog.Views.LocationsView
setSelectedId: (cityId) ->
Nhưng khi coffeescript mã biên dịch để javascript lớp kéo dài đôi ngoại hình của tôi như:
(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);
Và tôi đã nhận lỗi:
Uncaught TypeError: Cannot read property 'prototype' of undefined cities_view.js:5
Vì vậy, nơi mà vấn đề được và làm thế nào để sửa chữa nó?
Bạn có thể cung cấp dấu vết ngăn xếp đầy đủ không? – thejh