Monday, October 25, 2010

Undefined text in Page Editor when clearing field


You may be experiencing an issue with Page Editor in Sitecore 6.1/6.2 releases when clearing a field results in “Undefined” text being written back to your item.

To work this around, follow these 3 easy steps.

1. Locate the following file: <web root>\sitecore\shell\Applications\WebEdit\WebEditElement.js
Create a backup copy of it.

2. Find the following function: Sitecore.WebEdit.Element.prototype.load = function() and replace it with this:

Sitecore.WebEdit.Element.prototype.load = function() {
  if (this.element.getAttribute("scWatermark") == "true") {
    this.watermarkHTML = this.element.innerHTML;
  this.watermarkHTML = "[No text in field]";
  }".scWebEditFrameButtonIcon").each(function(icon) {
    icon.observe("dragstart", function(e) { e.stop(); });
  this.element.observe("click", this.onClick.bind(this));
  this.element.observe("blur", this.onBlur.bind(this));

3. Then locate this function: Sitecore.WebEdit.Element.prototype.isWatermark = function() {
and replace it with this:

Sitecore.WebEdit.Element.prototype.isWatermark = function() {
  if((this.watermarkHTML == this.element.innerHTML)||(this.element.innerHTML=="[No text in field]"))
  return fl;

Quick disclaimer: this proved working on my local 6.2.0 (rev. 100831) installation, however, this is not a fully tested solution, so there may be conflicts depending on exact version of your Sitecore instance and level of customization.

Thanks goes to Sitecore Customer Service for quick solution!