Nathan Leach
2006-May-11 15:12 UTC
[Rails] How do you make in_place_edit fields appear when empty?
Here''s a simple one... When using in_place_edit fields, they don''t appear unless they already have a value. How can I get similar functionality when they are empty? Thanks, Nathan -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060511/a98640cf/attachment.html
Nathan Leach
2006-May-11 20:19 UTC
[Rails] How do you make in_place_edit fields appear when empty?
Well, since I got a clamoring response to this question, I thought I would post
what I did back to the list. Maybe my hair-brained answer will evoke some
better solutions ;-)
The jist of it is that I query the contents of each field, and when empty put in
a default value (my choice was a "?"). That shows the user that a
value is needed and alows in_place_edit to show the field.
In the order view, with shipping point as the example field...
<% if @order.shippingpoint.empty? %>
<%= @order.shippingpoint = "?" %>
<% end %>
<%= in_place_editor_field :order, :shippingpoint %>
I would really like to see something that doesn''t involve custom code
for each field or putting garbage data in the field as a default value. I am no
Javascript expert (obviously). Maybe there is a nice solution using Javascript
helpers, etc.?
Nathan
-----Original Message-----
From: rails-bounces@lists.rubyonrails.org
[mailto:rails-bounces@lists.rubyonrails.org]On Behalf Of Nathan Leach
Sent: Thursday, May 11, 2006 10:12 AM
To: rails@lists.rubyonrails.org
Subject: [Rails] How do you make in_place_edit fields appear when empty?
Here''s a simple one...
When using in_place_edit fields, they don''t appear unless they already
have a value. How can I get similar functionality when they are empty?
Thanks,
Nathan
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://wrath.rubyonrails.org/pipermail/rails/attachments/20060511/9b58618c/attachment.html
Bryan Buecking
2006-Jun-27 04:20 UTC
[Rails] How do you make in_place_edit fields appear when empty?
See http://wiki.script.aculo.us/scriptaculous/show/Ajax.InPlaceEditor
near the bottom there''s a section called:
"Small extension to editor to add a text in case field is empty."
Nathan Leach wrote:> Well, since I got a clamoring response to this question, I thought I
> would post what I did back to the list. Maybe my hair-brained answer
> will evoke some better solutions ;-)
>
> The jist of it is that I query the contents of each field, and when
> empty put in a default value (my choice was a "?"). That shows
the
> user that a value is needed and alows in_place_edit to show the field.
>
> In the order view, with shipping point as the example field...
>
> <% if @order.shippingpoint.empty? %>
> <%= @order.shippingpoint = "?" %>
> <% end %>
> <%= in_place_editor_field :order, :shippingpoint %>
>
> I would really like to see something that doesn''t involve custom
code
> for each field or putting garbage data in the field as a default
> value. I am no Javascript expert (obviously). Maybe there is a nice
> solution using Javascript helpers, etc.?
>
> Nathan
>
> -----Original Message-----
> *From:* rails-bounces@lists.rubyonrails.org
> [mailto:rails-bounces@lists.rubyonrails.org]*On Behalf Of *Nathan
> Leach
> *Sent:* Thursday, May 11, 2006 10:12 AM
> *To:* rails@lists.rubyonrails.org
> *Subject:* [Rails] How do you make in_place_edit fields appear
> when empty?
>
> Here''s a simple one...
>
> When using in_place_edit fields, they don''t appear unless they
> already have a value. How can I get similar functionality when
> they are empty?
>
> Thanks,
> Nathan
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>