Originally Posted by spetsacdc
Hi, I am simply trying to implement the ajax in place editor system with scriptaculous.
Its easy to install the script and everything, but I am trying to do the extra part he talks about at the bottom:
Small extension to editor to add a text in case field is empty.
Now, I have everything working, but if you click the "click to edit..." thing that the extension adds to an empty field, then click cancel, the field goes blank instead of back to "click to edit..." so the user can't edit it unless he refreshes the page. Is this a bug? Anyone know how to edit the script to call the if empty function when they click cancel?
I've been toying with a fix for it, basically what it looks like is back in the summer from 1.6 - 1.8 InplaceEditor was completely rewrote.... onComplete is no longer called when you leave the field so it never checks to see if its empty.
If you change the code to read
Ajax.InPlaceEditor.prototype.__onComplete = Ajax.InPlaceEditor.prototype.onComplete;
Ajax.InPlaceEditor.prototype.__onComplete = Ajax.InPlaceEditor.prototype.leaveEditMode;
... if you do an alert inside the leaveEditMode you can see now it will kick off.. but I can't figure out for the life of me when it comes back.... this.element.innerHTML.length it equals 2... and if you alert this.element.innerHTML it comes back with %OA%OA and thats where i'm stuck unsure what OA is... i can cheat and tell it to check to see if the length is 0 or 2... and it will put the click to edit back.. but what happens whe your field actually only has 2 characters in it