2011-04-18 159 views

回答

0

我使用YUI3,但這可能仍然適用於YUI2。我使用execCommand('insertandfocus','content')添加內容,而不是使用內容初始化編輯器。

例如,而不是這樣的:

YUI().use('editor', function(Y) { 
    var yuiEditor = new Y.EditorBase({ 
    content: myPreloadedContent 
    }); 
    ... 
    yuiEditor.on('frame:ready', function() { 
    this.focus(); 
    }); 
    ... 
}); 

我將這樣的內容:

YUI().use('editor', function(Y) { 
    var yuiEditor = new Y.EditorBase(); 
    ... 
    yuiEditor.on('frame:ready', function() { 
    this.focus(function(){ 
     yuiEditor.execCommand('insertandfocus', myPreloadedContent); 
    }); 
    }); 
    ... 
});