I am writing my own WYSIWYG editor. For inserting URL's, images, etc. I
am not using html popups, but invisible DIV's of which I set the
visibility to "visible" whenever I need them.
Below are some parts of my code. It shows you the main function
txtEditor, which creates an object instance. On creation, I load
createPopups, which eventually has to write all "popups" to the
document body.
The situation is this: when I let the "image" popup DIV appear, and
click on the link, I get a "this.toolbarAction is not a function"
error.
So my question is: how should I then invoke toolbarAction from within
the popup DIV?
-----------------------------------------------------------------------
function txtEditor(textarea) {
var parent = textarea.parentNode;
this.textarea = parent.removeChild(textarea);
this.toolbar = this.createToolbar(textarea.name);
// etc (bouw de editor) ...
this.createPopups();
}
txtEditor.prototype.createPopups = function() {
var image = createNode('div', 'image', 'popup');
/****************** THIS LINE GENERATES AN ERROR ******************/
s = '<a onclick="this.toolbarAction(\'plain\', \'foobar!\')">x</a>';
image.innerHTML = s;
document.body.appendChild(image);
}
function createNode(type, name, style) {
var el = document.createElement(type);
el.id = name;
el.className = style;
return el;
}
txtEditor.prototype.toolbarAction = function(theAction, text) {
alert(theAction + ' - ' + text);
}
-----------------------------------------------------------------------
Any help would be greatly appreciated!
Dennis