I've a list of elements editable via a simple AJAX/jQuery edit button, which works great. But when I try editing the same field a second time it doesn't want to play ball.
- EDIT - AJAX returns a tinyMCE textarea containing content from MySQL
- SAVE - AJAX posts tinyMCE contents to MySQL and displays posted content
- EDIT (again) - Returns the same tinyMCE textarea and content as usual
- SAVE (again) - The second time save is attempted, returns error: g.win.document is null
Code snippets
var content = tinyMCE.get('content').getContent(); //get tinyMCE content
$("#edititem").load("editItem.php", {content: content}); //jQuery post
Solution - this is how I got it working:
EDIT - when editing, add the tinyMCE control to the textarea
tinyMCE.execCommand("mceAddControl",true,'content');
SAVE - when saving, remove the control for next time
tinyMCE.execCommand('mceRemoveControl',false,'content');