1

YUI2リッチテキストエディタをプリロードされたテキストでレンダリングしたい。ただし、カーソルは常にテキストの最初の位置にあります。テキストの最後に設定するにはどうすればよいですか?

ありがとう

4

1 に答える 1

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);
    });
  });
  ...
});
于 2011-04-30T14:51:09.293 に答える