jhollingworth / bootstrap-wysihtml5

Simple, beautiful wysiwyg editor
http://jhollingworth.github.com/bootstrap-wysihtml5/
MIT License
4.14k stars 1.01k forks source link

Cloning DOM element which is the el for a wysihtml5 instance #321

Open steinbachr opened 10 years ago

steinbachr commented 10 years ago

Great plugin! I have one small issue though. I need to clone a DOM element which contains an element I initialized a wysihtml5 instance with:

$('.target textarea').wysihtml5()

so I then do something like:

/* I need a deep clone */
var newContainer = $('.target').clone(true, true);

however, the textarea in the new container now has a textarea which is uneditable and doesn't include the value of the original text area.

I've tried to manually set the value of the editor in the new container using

newContainer.find('textarea').data('wysihtml5').editor.setValue('foo');

but this just sets the value of the original editor. I've also tried just creating a new instance of wysihtml5 on the textarea in the new container but that doesn't resolve the problem either. Any suggestions?