I have spent most of today trying to add and remove FCK editors via jquery. They add fine, remove the first time fine, but if you try to close the editor the second time, IE7 crashes and FF just does nothing! I'm using JQuery. I can't quite track down the issue but I think some event handlers are not being disposed of when the editor is deleted. Can anyone help! I'm pulloing my hair out!
function FckEdit(item) { var inEdit = $(item).hasClass("fckedit"); var fckid = 'fck_' + $(item).parents("div.ContentBlock:eq(0)").attr("name"); if (inEdit) { var c = oFCKeditor.Value; delete FCKeditorAPI.Instances['FCKeditor1' + ++fckcount]; oFCKeditor = false; var fckDiv = document.getElementById('fckDiv'); fckDiv.innerHTML = ''; //clear fckDiv.parentNode.removeChild(fckDiv); $(item).html(c); } else { oFCKeditor = new FCKeditor( 'FCKeditor1' + ++fckcount) ; oFCKeditor.BasePath = sBasePath; oFCKeditor.Height = 300; var content = $(item).html(); $(item).empty(); oFCKeditor.Value = content; var newdiv = document.createElement('div'); newdiv.setAttribute('id', 'fckDiv'); newdiv.innerHTML = oFCKeditor.CreateHtml(); $(item).append(newdiv); } $(item).toggleClass("fckedit"); }