|
I sorta handled this when I made my InPlaceDateEditor (code below). I
think this is a pretty good solution but one caveat is, it expects the
server to return '---' on empty input being submitted. To fix this
would require a non-default insertion to be used by the Ajax.Updater
and therefore a change to Ajax.InPlaceEditor.prototype.onSubmit as
well. I think SAU should be patched with an option added for
"blankText" defaulting to something like '---' and the relevant changes
I made to initialize and createEditField and the necessary changes to
onSubmit and a new insertion function that compares the responseText to
blankText. While IPE is being patched, it'd be nice if the JSON
evaluated response was available in onComplete. Colin ------------------ Ajax.InPlaceDateEditor = Class.create(); Object.extend(Ajax.InPlaceDateEditor.prototype, Ajax.InPlaceEditor.prototype); Object.extend(Ajax.InPlaceDateEditor.prototype, { initialize: function(element, url, options, calOptions) { this.calOptions = Object.extend({ ifFormat: "%a %m-%d-%y" }, calOptions || {}); Object.extend(new Ajax.InPlaceEditor(element, url, Object.extend({ formClassName:'date-ipe' },options||{})), this); if(Element.empty(element)) element.innerHTML = '---'; }, createEditField: function() { var text = this.getText(); if(text == '---') text = ''; var obj = this; this.options.textarea = false; var textField = document.createElement("input"); textField.obj = this; textField.type = "text"; textField.name = "value"; textField.value = text; textField.style.backgroundColor = this.options.highlightcolor; textField.className = 'editor_field'; var size = this.options.size || this.options.cols || 0; if (size != 0) textField.size = size; this.editField = textField; Calendar.setup(Object.extend(this.calOptions,{ inputField : this.editField, eventName: "focus" })); this.form.appendChild(this.editField); } }); ------------------ Tom Gregory wrote: It seems you'll need to either provide some default text, or tie the "begin edit" functionality to an external control (perhaps an "Edit" link, for example).Either approach would provide some sort of visual indicator of "editability," without relying on the user to discover the mouseover/ highlight behavior. http://wiki.script.aculo.us/scriptaculous/show/Ajax.InPlaceEditor shows how to do this: You can also arbitrarily force it into edit mode like so: var editor = new Ajax.InPlaceEditor('product_1',...); editor.enterEditMode('click'); With regard to HTML entities, there are several bugs open on the matter. Until it's part of the trunk (and it may be, I haven't checked recently), you may have to override some methods or use the callbacks. TAG On Sep 25, 2006, at 4:21 AM, Will Merrell wrote: --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs -~----------~----~----~----~------~----~------~--~--- |
- [Rails-spinoffs] Re: In place editing an empty field Colin Mollenhour
- [Rails-spinoffs] Re: In place editing an empty field Will Merrell
