<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
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.<br>
<br>
Colin<br>
<br>
------------------<br>
Ajax.InPlaceDateEditor = Class.create();<br>
Object.extend(Ajax.InPlaceDateEditor.prototype,
Ajax.InPlaceEditor.prototype);<br>
Object.extend(Ajax.InPlaceDateEditor.prototype, {<br>
initialize: function(element, url, options,
calOptions) {<br>
this.calOptions =
Object.extend({<br>
ifFormat: "%a %m-%d-%y"<br>
}, calOptions ||
{});<br>
Object.extend(new
Ajax.InPlaceEditor(element, url,
Object.extend({<br>
formClassName:''date-ipe''<br>
},options||{})),
this);<br>
if(Element.empty(element)) element.innerHTML =
''---'';<br>
},<br>
createEditField: function() {<br>
var text = this.getText();<br>
if(text == ''---'')
text = '''';<br>
var obj = this;<br>
<br>
this.options.textarea = false;<br>
var textField =
document.createElement("input");<br>
textField.obj =
this;<br>
textField.type =
"text";<br>
textField.name =
"value";<br>
textField.value =
text;<br>
textField.style.backgroundColor = this.options.highlightcolor;<br>
textField.className = ''editor_field'';<br>
var size = this.options.size ||
this.options.cols || 0;<br>
if (size != 0) textField.size =
size;<br>
this.editField =
textField;<br>
Calendar.setup(Object.extend(this.calOptions,{<br>
inputField : this.editField,<br>
eventName: "focus"<br>
}));<br>
this.form.appendChild(this.editField);<br>
}<br>
});<br>
------------------<br>
<br>
Tom Gregory wrote:
<blockquote
cite="mid8E21E672-0121-4265-9B65-2733FCF6A786-PGZyUNKar/Q@public.gmane.org"
type="cite">
<pre wrap="">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.
<a class="moz-txt-link-freetext"
href="http://wiki.script.aculo.us/scriptaculous/show/Ajax.InPlaceEditor">http://wiki.script.aculo.us/scriptaculous/show/Ajax.InPlaceEditor</a>
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:
</pre>
<blockquote type="cite">
<pre wrap="">I am trying to use the Scriptaculous
InPlaceEditor and in some
cases the
field will be empty. That is, the field currently has no value but the
user wants to enter a value.
The InPlaceEditor appears to not work in this case. Other identical
fields (except wit different ids and some value) do work.
I have tried using a nonbreaking space (&nbsp;), and this does
cause the
editor to appear, but then presents "&nbsp;" when the user
selects the
field. If I use a real space, the editor does not appear. I have
looked
at all of the documentation I could find and looked at the code, but
found nothing that seemed to address this issue.
How do you use the InPlaceEditor with empty data?
--Will Merrell
</pre>
</blockquote>
<pre wrap=""><!---->
.
</pre>
</blockquote>
<br>
--~--~---------~--~----~------------~-------~--~----~<br>
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group. <br> To post to this
group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <br> To
unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
<br> For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs <br>
-~----------~----~----~----~------~----~------~--~---<br>
</body>
</html>
<br>