I am pretty new to JavaScript and JQuery and I want to integrate the WYMEditor in a page. I want to do this dynamically by giving the user the possibility of having more then one WYMEditor or none. I am trying to do this like so:
I have a snippet that I will always clone and only change it's text property.
The snippet declaration
- Code: Select all
<div id="wymEditorSnippet" class="WymEditorBlock" style="WIDTH:100%">
<textarea id="wymEditor" class="wymeditor"></textarea>
</div>
The Add function
- Code: Select all
function AddWymEditorBlock(structure){
var snippet = $("#wymEditorSnippet").clone();
snippet.find("#wymEditor").val(structure.html);
return snippet;
}
The problem is that when the page is loaded, the JavaScript that replaces all objects that has [class="wymeditor"] with the WYMEditor controls. When I clone the snippet, I clone the entire WYMEditor, with the html of the first cloned object. The real problem is that those "blocks" added after page load do not work properly.
Please give me a hand with this, so I could have blocks that work properly, dynamically added.