私は CoffeeScript で Backbone.js を使用してプログラミングしていますが、lodash とマージ機能に関連する継承に問題があります。
スーパークラスがある
class NavigationView extends Backbone.View
config:
test:
string: "Test"
およびそれから派生した 2 つのクラス
class SubView extends NavigationView
initialize: ->
# Setting the view's template property using the Underscore template method
_.merge @config, {
test:
string: "bla"
}
class IndexView extends NavigationView
...
SubView の関数内で変更すると、config 変数が初期化され、IndexView のインスタンスでも変更されます。
BackBone.Router クラス内で、次のようにオブジェクトをインスタンス化します。
index: () ->
# Instantiates a new view which will render the header text to the page
new IndexView()
sub: () ->
new SubView()
それを示すためにフィドルを作成しました:http://jsfiddle.net/hijolan/9VeND/
それを行う方法はありますか?
よろしく、ヒジョラン