2012-05-21 87 views
1

我想用jwysiwyg jQuery插件https://github.com/akzhan/jwysiwyg與Ember.TextArea http://emberjs.com/,但我似乎無法得到綁定工作:(emberjs綁定和jwysiwyg

考慮下面的例子中,我已經使用了runloop在綁定啓動後調用.jwysiwyg jQuery插件(因此它包含正確的數據)

我不確定如何描述我的問題,但是在簡單的術語中,我無法獲取數據流向另一個當我更新文本區域中的數據(現在是一個html編輯器)時,模型不會更新。

<script> 
    App = Ember.Application.create(); 

    App.entry = Ember.Object.create({ 
     sometext: "some demo text in here" 
    }); 

    App.HTMLField = Ember.TextArea.extend({ 
     valueBinding: "App.entry.sometext", 
     didInsertElement: function() { 
      this._super(); 
      Ember.run.schedule('actions', this, function(){ 
       this.$().wysiwyg(); 
      }); 
     } 
    }); 
</script> 

<!-- place view in page --> 
<script type="text/x-handlebars"> 
    <p> 
     {{App.entry.sometext}} 
    </p> 
    <p> 
     {{view App.HTMLField}} 
    </p> 
</script> 

有沒有人知道解決問題的方法? ..解決方法的建議? ..任何指針? ...什麼可能有幫助?

回答

1

喜歡的東西應該這樣做:

App.HTMLField = Ember.TextArea.extend({ 
    didInsertElement: function() { 

     this._super(); 

     var self = this; 
     Ember.run.schedule('actions', this, function(){ 
      this.$().wysiwyg({ 
       events: { 
        save: function() { 
         var c = this.getContent(); 
         self.set('value', this.getContent()); 
        }, 
       }, 
      }); 
     }); 
    } 
});