I have Validation working across a large form (I fire it several times before Submit to check sections of the form), and a tinyMCE editor working in 1 textarea. I want to move the contents of the tinyMCE iframe into the textarea before (that's the key here - before) the Submit button is pressed so that the contents can be validated in the section before Submit.
I've used tinyMCE.triggerSave();
in several ways to move contents and then fire Validation before Submit. None work. I am beginning to believe that tinyMCE contents cannot be moved by any Javascript, rather contents move only via the Submit button, but I don't see that stated anywhere.
In tinyMCE, I've tried onchange_callback:
and handle_node_change_callback:
to fire functions with triggerSave and other saving commands. I can get the contents of tinyMCE to validate when I press Submit twice (others have noted this peculiarity), but not in any other way.
Also, when errors are corrected in tinyMCE, Validation does not revalidate until Submit is pressed. It should re-validate in real time, as Validation is designed to do.
2 questions -
Anyone know how to move tinyMCE contents into the textarea without hitting Submit?
Does CKEditor allow updates other than via Submit, and if so, where's a tutorial or example?
Here's an example of code that is supposed to be triggered by tinyMCE's onchange_callback, but only triggers upon the second click on Submit.
function tinyMCESetValue(inst)
{
var content = tinyMCE.activeEditor.getContent();
if (tinyMCE.activeEditor.isDirty()) {tinyMCE.triggerSave(true, true);}
// other save expressions that have been tried - with same results
//$("#selector").val(content);
//$("textarea.tinymce").val(content);
//tinyMCE.triggerSave();
//ed.save();
alert("some change"); //does not fire
}
In response to Thariama's comment, the above code is supposed to be triggered by the tinyMCEinit option of onchange_callback: "tinyMCESetValue",. I also have the following code in a JS section that does everything else correctly. The alert always shows 'undefined'. See any problem? Where else should I look/try? What tests can I do - I'm not getting useful info from Firebug.
if ($( "#sections" ).accordion( "option", "active" ) == 1) //if the second Accordion section
{
var content = tinyMCE.activeEditor.getContent(); //get the content from the tinyMCE iframe
if (tinyMCE.activeEditor.isDirty()) //if the contents of tinyMCE have changed}
{tinyMCE.triggerSave(true, true);} //put contents in the textarea
alert("|" + $("#detailedDescription").val() + "|tinyMCEval");
if (i == 7) {$("#detailedDescription").rules("add", {validCharsCheck: true});}
}
ENTER
key twice after a sentence).:)
– Jared Farrish