简体   繁体   English

emberjs绑定和jwysiwyg

[英]emberjs bindings and jwysiwyg

I would like to use jwysiwyg jQuery plugin https://github.com/akzhan/jwysiwyg with a Ember.TextArea http://emberjs.com/ , but I can not seem to get the bindings to work :( 我想使用带有Ember.TextArea http://emberjs.com/的 jwysiwyg jQuery插件https://github.com/akzhan/jwysiwyg ,但是我似乎无法使绑定起作用:((

Consider the example below, I have used the runloop thingy to call the .jwysiwyg jQuery plugin after the bindings have fired (so it contains the correct data). 考虑下面的示例,在绑定触发后,我使用了runloop whaty来调用.jwysiwyg jQuery插件(因此它包含正确的数据)。

I am unsure how to describe my problem, but in simplistic terms, I can not get the data to flow the other way ... ie. 我不确定如何描述我的问题,但以简单的方式来说,我无法使数据以其他方式流动...即。 when I update the data in the text area (now an html editor) the model does not get updated. 当我更新文本区域(现在是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>

Does anyone know of a way around the problem? 有谁知道解决这个问题的方法吗? .. suggestions of a workaround? ..解决方法的建议? .. any pointers? ..任何指针? ... anything that might help? ...可能有什么帮助吗?

Something like should do it: 应该采取以下措施:

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() );
                    },
                },
            });
        });
    }
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM