Rails 2.0.2 and in_place_edit? and Rich

Hello,

Can ANYONE please give me some help. I have TinyMCE installed and
working. However, I want to use it in an in_place_editor type of
fashion. I have tried many, many, many different things and simply
cannot get it to work.

I found examples (for example:
http://railsify.com/plugins/32-in-place-rich-editor) but that doesn’t
work out of the box. I kept getting function not defined for
onEnterEditMode so I finally created a version of it directly within
application.html.erb. So now, I don’t have any errors, but I don’t have
a rich edit box either! I am able to use the TinyMCE directly on the
page as long as it isn’t in_place. I have also tried reordering the
order in which js files are loaded.

I also ran into forgery errors when trying to just get in_place_editing
to work! I’m very frustrated because I feel like I have ran into issues
of some sort or another no matter which path I have gone down. For
anyone else just trying to use in_place_editXXX getting the forgery
errors you can do this:

protect_from_forgery :except => [:set_YourObject_YourField]

I sincerely appreciate anyone who has a working sample on Rails 2.0.x
with a WYSIWYG editor cause I couldn’t even get FCKEditor to work on 2.x
thus the path of TinyMCE.

Thanks in advance,

Michael

On 1/11/08, Michael M. [email protected] wrote:

I also ran into forgery errors when trying to just get in_place_editing
to work! I’m very frustrated because I feel like I have ran into issues
of some sort or another no matter which path I have gone down. For
anyone else just trying to use in_place_editXXX getting the forgery
errors you can do this:

protect_from_forgery :except => [:set_YourObject_YourField]

Some of the Rails helpers (currently) require you to add the
:form_authenticity_token yourself:

Try adding this into the :url_for portion of your helper call, it
usually fixes it for me:

:form_authenticity_token => form_authenticity_token


Greg D.
http://destiney.com/

Hi,

Not sure if this issue is still open, but I have an updated patch to the
one mentioned below for the latest TinyMCE and Scriptaculous.

I’ve attached the in_place_edit change. The modified javascript is
below:

// TinyMCE RichEdit Widget for Scriptaculous from
http://dev.rubyonrails.org/ticket/5263

Ajax.InPlaceRichEditor = Class.create();
Object.extend(Ajax.InPlaceRichEditor.prototype,
Ajax.InPlaceEditor.prototype);
Object.extend(Ajax.InPlaceRichEditor.prototype,{
createEditField: function() {
var text = (this.options.loadTextURL ? this.options.loadingText :
this.getText());
var fld;
if (1 >= this.options.rows && !/\r|\n/.test(this.getText())) {
fld = document.createElement(‘input’);
fld.type = ‘text’;
var size = this.options.size || this.options.cols || 0;
if (0 < size) fld.size = size;
} else {
fld = document.createElement(‘textarea’);
fld.rows = (1 >= this.options.rows ? this.options.autoRows :
this.options.rows);
fld.cols = this.options.cols || 40;
}
fld.name = this.options.paramName;
fld.value = text; // No HTML breaks conversion anymore

// TinyMCE edit
fld.id = 'mce_editor_field';

fld.className = 'editor_field';
if (this.options.submitOnBlur)
  fld.onblur = this._boundSubmitHandler;
this._controls.editor = fld;
if (this.options.loadTextURL)
  this.loadExternalText();
this._form.appendChild(this._controls.editor);

},
enterEditMode: function(e) {
if (this._saving || this._editing) return;
this._editing = true;
this.triggerCallback(‘onEnterEditMode’);
if (this.options.externalControl)
this.options.externalControl.hide();
this.element.hide();
this.createForm();
this.element.parentNode.insertBefore(this._form, this.element);

tinyMCE.execCommand('mceAddControl', false, 'mce_editor_field');

if (!this.options.loadTextURL)
  this.postProcessEditField();
if (e) Event.stop(e);

},
handleFormSubmission: function(e) {
tinyMCE.triggerSave();

var form = this._form;
var value = $F(this._controls.editor);
this.prepareSubmission();
var params = this.options.callback(form, value) || '';
if (Object.isString(params))
  params = params.toQueryParams();
params.editorId = this.element.id;
if (this.options.htmlResponse) {
  var options = Object.extend({ evalScripts: true }, 

this.options.ajaxOptions);
Object.extend(options, {
parameters: params,
onComplete: this._boundWrapperHandler,
onFailure: this._boundFailureHandler
});
new Ajax.Updater({ success: this.element }, this.url, options);
} else {
var options = Object.extend({ method: ‘get’ },
this.options.ajaxOptions);
Object.extend(options, {
parameters: params,
onComplete: this._boundWrapperHandler,
onFailure: this._boundFailureHandler
});
new Ajax.Request(this.url, options);
}
if (e) Event.stop(e);
},
removeForm: function() {
if (!this._form) return;
tinyMCE.execCommand(‘mceRemoveControl’, false, ‘mce_editor_field’);
this._form.remove();
this._form = null;
this._controls = { };
}
});
// tinyMCE.addMCEControl(this._controls.editor, ‘value’);

Michael Modic wrote:

Hello,

Can ANYONE please give me some help. I have TinyMCE installed and
working. However, I want to use it in an in_place_editor type of
fashion. I have tried many, many, many different things and simply
cannot get it to work.

I found examples (for example:
http://railsify.com/plugins/32-in-place-rich-editor) but that doesn’t
work out of the box. I kept getting function not defined for
onEnterEditMode so I finally created a version of it directly within
application.html.erb. So now, I don’t have any errors, but I don’t have
a rich edit box either! I am able to use the TinyMCE directly on the
page as long as it isn’t in_place. I have also tried reordering the
order in which js files are loaded.

I also ran into forgery errors when trying to just get in_place_editing
to work! I’m very frustrated because I feel like I have ran into issues
of some sort or another no matter which path I have gone down. For
anyone else just trying to use in_place_editXXX getting the forgery
errors you can do this:

protect_from_forgery :except => [:set_YourObject_YourField]

I sincerely appreciate anyone who has a working sample on Rails 2.0.x
with a WYSIWYG editor cause I couldn’t even get FCKEditor to work on 2.x
thus the path of TinyMCE.

Thanks in advance,

Michael

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs