2012-10-05 14 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