empty text for Ajax.InPlaceEditor
I was playing with the Scriptaculous Ajax.InPlaceEdit control this afternoon, and realised it didn’t support having “empty” text (default text to show if there was nothing to edit).
Someone on the Wiki had a partial solution, but it’s a little out of date and wasn’t working for us 1.6-ers (Doesn’t use the cool new $super stuff).
So I wrote my own! Enjoy :)
AjaxInPlaceEditorWithEmptyText = ClasscreateAjaxInPlaceEditor
if !optionsemptyText optionsemptyText = "click to edit...";
if !optionsemptyClassName optionsemptyClassName = "inplaceeditor-empty";
$superelementurloptions;
thischeckEmpty;
if thiselementinnerHTMLlength == 0 && thisoptionsemptyText
thiselementappendChild
"span" className : thisoptionsemptyClassName updatethisoptionsemptyText
;
if empty_span = thiselementselect"." + thisoptionsemptyClassNamefirst
empty_spanremove;
return $super;
thischeckEmpty;
return $supertransport;
;




Nik Wakelin
Oliver Clarke
Man, Javascript looks trashy with short lines…. copy + paste may be in order :)