TinyMCE - setting contents in editor

Permalink
I've trying to set contents to a TinyMCE editor in a block add/edit screen.
tinyMCE.init({mode:"textareas"});
tinyMCE.get("editor").setContent("test");
// when alert runs, the editor has content "test"
// but after the alert, the contents are removed.
alert("look at editor now");


I have tried to make a standalone example, but in this example the tinyMCE sets up the editor, but javascript stops running at the line below the init of tinyMCE, so the content is never set because instances are not available trough tinyMCE.get or tinyMCE.activeEditor.

// edit this next line to point to your tinyMCE folder
<script type="text/javascript" src="tinymce_392/tiny_mce.js"></script>
<script type="text/javascript">
    tinyMCE.init({
        mode : "textareas"
    });
    // set new value to the editor
    tinyMCE.get("editor").setContent("This value will not appear in editor");
    // Give popup to see that line above works
    alert("This does not run");
</script>
<form method="post" action="">
    <textarea id="editor"></textarea>
    <button type="button" onclick="tinyMCE.get('editor').setContent('Button click works');">Set content</button>
</form>


Can anyone help me put contents in the editor automatically?

itrio