2012-10-05 15 views

回答

1

[...]但據我所知,我canot只是用卓別林

當列表的相關直接與他們

可以直接修改它們,只要你適當地委託擴展原型。

由於您還沒有爲您的問題javascriptcoffeescript加上標籤,因此以下是每種解決方案的兩種解決方案。首先是JavaScript。注意我們必須明確地調用擴展函數。

var View = Chaplin.View.extend({ 
    initialize: function(options) { 
    // Add code here .. 

    // The below invokes the initialize function of the 
    // base Chaplin.View class in the context of 
    // this class 
    Chaplin.View.prototype.initialize.call(this, arguments); 

    // .. or here 
    } 
}); 

接下來是coffeescript,這使得這種事情更容易。

class View extends Chaplin.View 
    initialize: -> 
    // Add code here .. 

    // The below auto-magically invokes the 
    // initialize method of the base class 
    super 

    // .. or here 
+0

啊,所以我只是創建我自己的初始化方法,並從內部調用卓別林的初始化方法。知道了謝謝 :) – ragulka