Tag Archives: yui rte

YUI RTE setEditorHTML….

var myEditor = new YAHOO.widget.Editor('editor', config);
myEditor.on('editorContentLoaded', function() {
myEditor.setEditorHTML('This is my new content');
});
myEditor.render();

要 listening editorContentLoaded event 才行
沒在editorContentLoaded 裡下………….
myEditor.setEditorHTML(‘This is my new content’);
沒作用………

Posted in program | Tagged | Leave a comment

some YUI RTE note..

在<body> 這個tag 似乎一定要設
class=’yui-skin-sam’
不然會有一些小問題
我之前是設在<div class=’yui-skin-sam’><textarea></textarea></div>
這樣來解 ..不過…
用了一陣子才發現….class=’yui-skin-sam’不是設在body 的話….
add link 的這個func 會破版…………..css 會整個走掉….
本來是沒有很想加 class 在body 的..
不過突然想到….drupal 的 plugin 中也有yui rte
我就去看了一下他是怎麼解的..

<script type="text/javascript">
if (Drupal.jsEnabled) { $(document).ready(function() { $('body').addClass('yui-skin-sam'); } ); };
</script>

然後看了一下skin裡面的css 應該是不至於加了這個class 造成新版的走位,所以就照著幹了…

Posted in program | Tagged | Leave a comment

YUI Rich Text Editor 小記

因為有打算用YUI RTE 來做default 的editor
不過因為有想要在textarea 裡面加入content 的須求
用document.post_form.post_text.value
會沒辦法在”所見即所得模式”下有反應
只能在原始碼模式下有作用
翻了一下文件
要用cmd_inserthtml來做
如下

myEditor = YAHOO.widget.EditorInfo.getEditorById('post_text');
myEditor.execCommand('inserthtml', document.post_form.post_text.value);

這樣應該就搞定了…

Posted in program | Tagged | Leave a comment