2011-04-18 158 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); 
    }); 
    }); 
    ... 
});