REF:this jsfiddleRACTIVEは:別のモデルから1つのモデルのメソッドを実行
私はRACTIVEモデルを持っている(これはRACTIVE質問やプレーン古いjavascriptの質問がある場合、私は知りません)、 "アイテム":モデルは次のようになります別 RACTIVEモデル、二つの属性を初期化することを
window.item = new Ractive({
el: "#container",
template: "<p>words</p>",
oninit: function() { window.little_ractive.set({ 'thing_to_do': this.do_this, 'item': this }); },
do_this: function() { this.say("yeah baby"); },
say: function(what) { console.log(what); }
});
は予告:
window.little_ractive = new Ractive({
finish: function() { this.get('thing_to_do').apply(this.get('item')); }
});
little_ractiveは、アイテムモデルとその "do_this"メソッドを指す属性で正しく初期化されていることがわかります。
我々は今実行している場合:(「本」)が間違って「do_this」方法に設立され、それがエラーを返している
little_ractive.finish()
コンテキスト「(this.say)の機能ではありません」
どのように1つのRactiveモデルのメソッドを別のものから実行できますか?
更新: jsfiddleはRactiveバージョン1.0.0 build9を使用しています。 Ractiveバージョン0.7.3ではこの問題は発生しません。期待どおり動作します。
更新:予期しない動作は、第0.8.0