I have a dynamically created textarea and like to replace it with jwysiwyg.
I tried to add the function in PHP template
<script type="text/javascript">$(function(){$('#wysiwyg').wysiwyg();}); </script>
and in js file
njuid= ""+ actual.id +"_field";
act.innerHTML = "<textarea name=\"textarea\" id=\""+ act.id +"_field\" onblur=\"noLight (this); return fieldBlur(this,'" + actual.id + "');\">" + actual.innerHTML + "</textarea>
<script>$(function(){$('#+njuid').wysiwyg();});</script>";
without success. How can I replace the textarea?
I would recommend using jQuery to help you with the DOM manipulation. I have been able to create jWysiwyg dynamically in my pages by using the following strategy:
1) Append the textarea to the DOM wherever you need to. Do not set the contents of the textarea yet!
2) Create your wysiwyg and add whatever text you want to load into it as follows: