Reputation: 7279
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.
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');
Upvotes: 5
Views: 10089
Reputation: 360
For tinymce 3.2.x, use the following to remove tinyMCE instance in IE8 or any other browser. As tinymce.execCommand function makes input fields uneditable in IE8.
tinyMCE.remove(editor); //editor is instance of tinymce editor and not editor id
This will fix "Permission Denied" error without disabling other input fields in the same page.
Upvotes: 0
Reputation: 21
$(tinyMCE.editors).each(function(){
tinyMCE.remove(this);
});
Upvotes: 2
Reputation: 3556
Just thought I'd add a workaround solution that works in combination with the solution above:
setTimeout(function() {tinyMCE.execCommand("mceAddControl", true, "content");}, 5);
For whatever reason, I'm not sure if it's a timing issue with the DOM manipulation or something else, but a tiny delay makes life better. However the setTimeout()
did NOT work in combination with using a jQuery .each()
method, such as:
$("textarea").each(function(index) {
tinyMCE.execCommand("mceAddControl", false, $(this).attr("id"));
});
That must be a whole different timing issue.
Anyhoo, thought I'd share these findings as I'm sure others and even possibly me again will find this posting helpful.
Upvotes: 2
Reputation: 39940
I am more familiar with FCKeditor but I think it is similar. TinyMCE has mceAddControl command to add/create editor instances. Are you doing that after you reload your content?
tinyMCE.execCommand('mceAddControl' ...
Upvotes: 1