Javascript: YUI rich text editor fails to save text

Posted on January 21, 2010

5


Last night I found another strange problem when writing a code using Yahoo User Interface 2 (YUI 2). I used YUI 2 rich text editor and found that whatever I typed in that editor would not be passed to my server-side scripting. I actually started my debugging from the backend porting, making sure that whatever I wrote worked perfectly fine and, finally, I realized that actually the rich text editor didn’t give my script the text.

After a while, I started to realize that the rich text editor didn’t automatically update its own; I am not really sure where the rich text editor keeps my typing. So, I need to save whatever I typed to the rich text editor first before the form submitted to the server-side scripts. This is how I do it:

function onReviewSubmit(p_oEvent) { myEditor.saveHTML(); }

YAHOO.util.Event.on("my-form", "submit", onReviewSubmit);

var myEditor = new YAHOO.widget.SimpleEditor('my-editor', myConfig);
myEditor.render();

In short, I made my javascript to subscribe to form submit event, ensuring whatever I wrote was saved before submitting. It is interesting, isn’t it? – Made me scratching my head for hours.

Advertisements
Tagged: ,
Posted in: MyWay