Frederick Cheung wrote:
> On Aug 16, 5:25�am, Greg Willits <[email protected]>
> wrote:
>> when the form uses a form_remote_tag.
>>
>> Is there a simple, universal process for this, or does it really take 40
>> lbs of hacks to accomplish like the blogs all seem to suggest?
>>
> It should be reasonably straightforward to re-render the entire form.
> It might get more complicated if you want to be cleverer that that. I
> suppose you could have a div/span with a predictable id next to each
> field then loop over object.errors, inserting relevant content into
> each of these div/spans

So far I have something like this in the controller. Similar to what I'd 
do for a non-Ajax routine.

if @object.custom_save
  respond_to do |request_format|
    request_format.js
  end
else
  render :action => 'edit_method'
end

The view rendered by edit_method uses something like this:

<% if @object.errors.on(:field_name) -%> ERROR <% end -%>
<input type="text" ...etc... />

The RJS is pretty basic like this:

page.replace_html 'formID', :partial => the_path, :locals => {:object => 
@object}

The page starts with a div for viewing data only. Click and Edit button, 
and it is replaced with an editable form which includes a Save button.

By the time the controller gets to render :action, it seems like the rjs 
is ineffective. AFAICT (visually) there's no actual updating of the HTML 
via RJS.

-- gw



-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" 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-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to