开发者

YUI Rich Text Editor: How to set the cursor to the end of the text

i want to render a YUI2 Rich Text Editor with some preloaded text. But the cursor is always in the first position of the text. How can i set it at the end of the t开发者_C百科ext?

Thanks


I'm using YUI3, but this might still work for YUI2. I'm adding the content with execCommand('insertandfocus','content') rather than initializing the editor with the content.

For instance, instead of this:

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

I'm inserting the content like this:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜