I set up better-edit-in-place but still cannot edit in place in Rails
- by Angela
I installed the plugin better-edit-in-place (http://github.com/nakajima/better-edit-in-place) but I dont' seem to be able to make it work.
When I use firebug, it is rendering the value to be edited correctly:
<span rel="/emails/1" id="email_1_days" class="editable">7</span>
And it is showing the full javascript which should work on class editable:
var Editable = Class.create({
5 initialize: function(element, options) {
6 this.element = $(element);
7 Object.extend(this, options);
8
9 // Set default values for options
10 this.editField = this.editField || {};
11 this.editField.type = this.editField.type || 'input';
12 this.onLoading = this.onLoading || Prototype.emptyFunction;
13 this.onComplete = this.onComplete || Prototype.emptyFunction;
14
15 this.field = this.parseField();
16 this.value = this.element.innerHTML;
17
18 this.setupForm();
19 this.setupBehaviors();
20 },
21
22 // In order to parse the field correctly, it's necessary that the element
23 // you want to edit in place for have an id of (model_name)_(id)_(field_name).
24 // For example, if you want to edit the "caption" field in a "Photo" model,
25 // your id should be something like "photo_#{@photo.id}_caption".
26 // If you want to edit the "comment_body" field in a "MemberBlogPost" model,
27 // it would be: "member_blog_post_#{@member_blog_post.id}_comment_body"
28 parseField: function() {
29 var matches = this.element.id.match(/(.*)_\d*_(.*)/);
30 this.modelName = matches[1];
31 this.fieldName = matches[2];
32 if (this.editField.foreignKey) this.fieldName += '_id';
33 return this.modelName + '[' + this.fieldName + ']';
34 },
But when I point my mouse at the element, no in-place-editing action!