Hi,
I have the following:
_list_user.rhtml
_____________________________________
<table>
<tr>
<% for column in User.content_columns %>
<th><%= column.human_name %></th>
<% end %>
</tr>
<% for user in @users %>
<tr>
<% for column in user.content_columns %>
<td><%=h user.send(column.name) %></td>
<% end %>
<td><%= link_to ''Edit'', :action =>
''user'', :id => user, :user_info
=> @user_info %></td>
<td><%= link_to ''Destroy'', { :action =>
''destroy_user'', :id =>
user, :user_info => @user_info }, :confirm => ''Are you
sure?'', :post
=> true %></td>
</tr>
<% end %>
</table>
_______________________________________
user.rhtml
_______________________________________
<div id="list_user">
<%= render :partial => ''list_user'', :user_info =>
@user_info %>
</div>
<% form_remote_tag :url => { :action =>
''update_user'', :id =>
@user, :user_info => @user } do %>
<%= render :partial => ''user_form'' %>
<%= submit_tag ''Save'' %>
<% end %>
_______________________________________
update_user.rjs
_______________________________________
page.replace_html("list_user", :partial =>
''list_user'', :user_info =>
@user_info )
______________________________________
For some reason, when I click on "Save", it doesn''t update
the
_list_user.rhtml partial. In fact, it updates the model but the
partial doesn''t refresh. Is there something wrong with the partial?
I put page.alert(''RJS works!'') in my update_user.rjs and that
works...
Thanks in advance!
--~--~---------~--~----~------------~-------~--~----~
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
So I looked into this a little more and it seems like the new updated data doesn''t get refreshed right after I click "save". When I refresh the page again, that''s when the data is refreshed. I''m not sure how the form submits to the server, but apparently the page.replace_html happens BEFORE the data is submitted. Any ideas? On Mar 2, 10:55 pm, "wcheung" <indiffere...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > > I have the following: > > _list_user.rhtml > _____________________________________ > > <table> > <tr> > <% for column in User.content_columns %> > <th><%= column.human_name %></th> > <% end %> > </tr> > > <% for user in @users %> > <tr> > <% for column in user.content_columns %> > <td><%=h user.send(column.name) %></td> > <% end %> > > <td><%= link_to ''Edit'', :action => ''user'', :id => user, :user_info > => @user_info %></td> > <td><%= link_to ''Destroy'', { :action => ''destroy_user'', :id => > user, :user_info => @user_info }, :confirm => ''Are you sure?'', :post > => true %></td> > </tr> > <% end %> > </table> > _______________________________________ > > user.rhtml > _______________________________________ > > <div id="list_user"> > <%= render :partial => ''list_user'', :user_info => @user_info %> > </div> > > <% form_remote_tag :url => { :action => ''update_user'', :id => > @user, :user_info => @user } do %> > <%= render :partial => ''user_form'' %> > <%= submit_tag ''Save'' %> > <% end %> > _______________________________________ > > update_user.rjs > _______________________________________ > > page.replace_html("list_user", :partial => ''list_user'', :user_info => > @user_info ) > ______________________________________ > > For some reason, when I click on "Save", it doesn''t update the > _list_user.rhtml partial. In fact, it updates the model but the > partial doesn''t refresh. Is there something wrong with the partial? > I put page.alert(''RJS works!'') in my update_user.rjs and that > works... > > Thanks in advance!--~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 3/3/07, wcheung <indifferenze-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I have the following:[...]> For some reason, when I click on "Save", it doesn''t update the > _list_user.rhtml partial. In fact, it updates the model but the > partial doesn''t refresh. Is there something wrong with the partial? > I put page.alert(''RJS works!'') in my update_user.rjs and that > works...The explanation I can think of is that you didn''t fetch the @users in the update_user action in your controller. That''s how you see the data when you refresh the page (since you must have fetched @users in your users action) but not in the RJS update. d. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hmm..I have @users in update_user action (it was complaining before in the log). But it''s still not updating the data before the page.replace_html. Any other ideas? Is there anything I''m doing wrong with the form? On Mar 3, 1:29 am, "Lukhnos D. Liu" <lukh...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 3/3/07, wcheung <indiffere...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > I have the following: > [...] > > For some reason, when I click on "Save", it doesn''t update the > > _list_user.rhtml partial. In fact, it updates the model but the > > partial doesn''t refresh. Is there something wrong with the partial? > > I put page.alert(''RJS works!'') in my update_user.rjs and that > > works... > > The explanation I can think of is that you didn''t fetch the @users > in the update_user action in your controller. That''s how you see > the data when you refresh the page (since you must have fetched > @users in your users action) but not in the RJS update. > > d.--~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 3/3/07, wcheung <indifferenze-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hmm..I have @users in update_user action (it was complaining before in > the log). But it''s still not updating the data before the > page.replace_html. Any other ideas? Is there anything I''m doing > wrong with the form?Having re-read your snippets, there is one line that really troubles me: page.replace_html("list_user", :partial => ''list_user'', :user_info=>@user_info ) I don''t think this line will work. Your partial is using the @user_info in the controller, that the one passed by the line above. So if your action doesn''t fetch @user_info, there''s no data for the partial to use. To pass a "local variable" to the template, pass :locals=>{:user_info=>@user_info} in the render parameter, then replace the member variable @user_info with user_info in the partial. Hope this works. d. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---