Apr
23rd
Thu
23rd
Update to YUI Editor Code View Problem
I over complicated things in my previous solution, and found a better solution while trying to get the WYSIWYG editor to work inside an AJAX form using rails’ remote_form_for.
Using the YUI editor example, set handleSubmit to false and add this right after the MyEditor.render();
// Nate's better Handle Submit
function myHandleFormSubmit(e){
if(state == 'off') {
myEditor.cleanHTML();
};
};
Event.on(myEditor.get('element').form, 'submit', myHandleFormSubmit, myEditor, true);
When doing this and using a AJAX form, try this:
// Nate's better Handle Submit (AJAX version)
function myHandleFormSubmit(e){
if(state == 'off') {
myEditor.cleanHTML();
};
Connect.setForm(e.target);
Connect.asyncRequest('POST', e.target.action, callback, '_method=put');
Event.stopEvent(e);
};
var handleSuccess = function(o){ eval(o.responseText); };
var callback = { success:handleSuccess };
Event.on(myEditor.get('element').form, 'submit', myHandleFormSubmit, myEditor, true);
Hope this helps