2016-04-27 38 views
2

ember.run.bindを動作させようとしていますが、動作していないようです。私はあなたが呼び出すことができる機能を返すEmber.run.bind()すべての組み合わせEmber.run.bindが機能していません

_didInsertElement: Ember.on('didInsertElement', function() { 
    Ember.run.bind(this, this.doSomething); 
    }) 

または

_didInsertElement: Ember.on('didInsertElement', function() { 
    Ember.run.bind(this, function() { 
     this.doSomething(); 
    }); 
    }) 

または

_didInsertElement: Ember.on('didInsertElement', function() { 
    var _this = this; 
    Ember.run.bind(this, function() { 
     _this.doSomething(); 
    }); 
    }) 

答えて

2

を試してみました。これは非同期実行のためのものです。すぐに呼び出されるとは限りません。すぐに呼び出す場合は、bindを使用する必要はありません。

var func = Ember.run.bind(this, this.doSomething); 

func(); 

http://emberjs.jsbin.com/diqelezika/edit?html,js,output

+0

ハ私はこれを試してみましたはずですが、私はこれがそれであることができなかったと感じ、感謝の束 – wallop

関連する問題