Search code examples
formscakephpyui-editor

cakePHP form with YUI text editor, not working


I am trying to integrate yui editor in a cakephp form the editor is attached to the textarea, I tried the handleSubmit option and it didn't work, so I went trying manual. so- I've attached a listener to the onsubmit, which is working.. or not.

Editor initialization ( a copy-paste from yui site, only element named changed):

(function() {
    //Setup some private variables
    var Dom = YAHOO.util.Dom,
        Event = YAHOO.util.Event;  
        //The SimpleEditor config
        var myConfig = {
            height: '300px',
            width: '99%',
            focusAtStart: true
        };

    //Now let's load the SimpleEditor..
    var myEditor = new YAHOO.widget.SimpleEditor('ArticleContent', myConfig);
    myEditor.render();
})();

Initialization works fine (I assume) since the editor now holds the real content of that record field.

The onsubmit listener function:

function setTextArea()
{
alert('s');  
var dd = myEditor.saveHTML();  
alert('d');
return false;
}

The first alert is working, so the event is handled. However, the second alert never happens. the form - somehow - is submitted before it. and, the content is not saved.

further checks shows that ANY call to myEditor [even alert(myEditor)] is submitting the form...

anyone? help? i


Solution

  • The best solution was to use tinyMCE....