2014-11-05 165 views
0

第一次点击后,我想更改我的.on()方法。如何覆盖Famo.us中的.on()方法

mySurface.on("touchstart",function(){ 
     doSomething();  
}) 

和之后的第一个点击我想改变它,例如到:

mySurface.on("touchstart",function(){ 
     doSomethingDifferent();  
}) 

我如何可以覆盖我的。对方法?

回答

0

这里覆盖了.on()方法并不是真的需要你的情况。

以下是处理您的用例的一种方法。

var doSomethingElse = function(event) { 
    console.log('doSomethingElse', event); 
    console.log('mySurface', this); 
    }; 

    var doSomething = function(event) { 
    console.log('doSomething', event); 
    console.log('mySurface', this); 
    func = doSomethingElse; 
    }; 

    var func = doSomething; 

    mySurface.on("touchstart",function(event){ 
    func.call(this, event);  
    });