Ok gang,
I am trying to enhance my activity module (Teacher Plan) by adding a button (<input type="button"....) which produces a popup window. From this window you can browse all the activities in the course and get a direct link to them. I want to update an HTML-savvy textarea (i.e. HTMLArea) control with the link created in the popup window using Javascript. The problem is that while I can add it when the bare HTML is visible (i.e. the control is displayed as a textarea, so I use textarea.value += html), I cannot update the HTML in the HTMLArea. Any function call to editor.insertHTML(html) fails. Here is a snippet:
<?php
use_html_editor('plan');
use_html_editor('assessment');
use_html_editor('materials');
print_footer($course);
?>
<script type="text/javascript" defer="defer">
<!--
var html_match = 'plan', edit_plan],
['assessment', edit_assessment],
['materials', edit_materials;
function insertToTextArea(recvname, html) {
for (var i = 0; i < html_match.length; i++) {
if (html_match[i][0] == recvname) {
alert("Found "+recvname);
// Make sure that editor has focus
html_match[i][1].focusEditor();
html_match[i][1].insertHTML(html); // inserts contents
}
}
}
-->
</script>
This code is in the parent window. When I call opener.insertToTextArea('materials', mylink) from the popup window, I get the proper alert message, but both focusEditor and insertHTML fail.
Any ideas how to do this? I am guessing that I am not getting the proper HTMLArea pointer, thus making the function call invalid, but I do not know how to fix that problem. Any help is appreciated.
In reply to Josh Bush
Re: Help adding HTML to HTMLArea in parent window from a popup window
by Janne Mikkonen -
The editor is actually a frame ( iframe ) with single contenteditable document in it. So to access that contenteditable area you'll have to check frames for that page.
Other method is to override existing config and register new button at the toolbar to interact with the editor. http://itools-htmlarea.cvs.sourceforge.net/itools-htmlarea/htmlarea/examples/
- Janne -
Other method is to override existing config and register new button at the toolbar to interact with the editor. http://itools-htmlarea.cvs.sourceforge.net/itools-htmlarea/htmlarea/examples/
- Janne -