Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #5897 (closed defect: untested)

Opened 2 years ago

Last modified 2 years ago

[PATCH] Ajax.InPlaceEditor: using the external control to turn editing on shouldn't be in addition to clicking on the field itself

Reported by: spacedub@gmail.com Assigned to: thomas@fesch.at
Priority: high Milestone:
Component: script.aculo.us Version:
Severity: normal Keywords:
Cc:

Description

With the Ajax.InPlaceEditor control, if you set the externalControl option to an existing control, then you will be able to turn the editing mode on by both

1) Clicking on the field itseld.

2) clicking on the external control.

It should be one or the other (i.e. {1 or 2}, not {1 or {1 or 2}} ).

Imagine you have read-only fields and then a little 'edit' icon next to them. You want the readonly fields to be clickable (like a url), but editable also (when you click on the 'edit' icon, which is actually your externalControl). This cannot be done right now.

To fix it, just change the code in control.js > Ajax.InPlaceEditor class > this.options = Object.extend({ ...

OLD (CURRENT) CODE

    Event.observe(this.element, 'click', this.onclickListener);
    Event.observe(this.element, 'mouseover', this.mouseoverListener);
    Event.observe(this.element, 'mouseout', this.mouseoutListener);
    if (this.options.externalControl) {
      Event.observe(this.options.externalControl, 'click', this.onclickListener);
      Event.observe(this.options.externalControl, 'mouseover', this.mouseoverListener);
      Event.observe(this.options.externalControl, 'mouseout', this.mouseoutListener);
NEW (PROPOSED) CODE

	if (this.options.externalControl) {
	  Event.observe(this.options.externalControl, 'click', this.onclickListener);
	  Event.observe(this.options.externalControl, 'mouseover', this.mouseoverListener);
	  Event.observe(this.options.externalControl, 'mouseout', this.mouseoutListener);
	} else {
	  Event.observe(this.element, 'click', this.onclickListener);
	  Event.observe(this.element, 'mouseover', this.mouseoverListener);
	  Event.observe(this.element, 'mouseout', this.mouseoutListener);
	}

Change History

09/03/06 18:56:53 changed by madrobby

  • status changed from new to closed.
  • resolution set to untested.