I am trying to use WYSIHTML5 with Rails nested forms, using the nested_form gem.
My initial problem came up when generating a new set of fields through nested_form’s link_to_add feature. From what I understand, it duplicates a pre-generated field (the “blueprint”). WYSIHTML5 uses iFrames and the iFrame content wasn’t being copied over. The body was missing a contenteditable attribute, so it was pretty much useless. I managed to copy over all the missing attributes with nested_form’s nested:fieldAdded javascript trigger.
So now everything is editable and looks right. New problem. The iframe is apparently not tied to the original textarea. I can type whatever I want to, but it doesn’t get submitted with the form. I can’t figure out what I’m missing here. The iframe doesn’t have any id attribute or seemingly anything that would tie the two together.
Any help would be appreciated. If I left out any details, let me know.
Manually linking everything together turned out to be too much of a pain.
I basically ended up ignoring the blueprint textarea with
$('.wysiwyg:not([id$="_blueprint"] .wysiwyg)'). Then on thenested:fieldAddedjQuery trigger, I select$('.wysiwyg-inactive:not([id$="_blueprint"] .wysiwyg)')and activate them, usingwysiwyg-inactiveandwysiwyg-activeclasses to make sure I don’t double activate themSort of clean. Sort of simple. But there you have it.