RJS to refresh partial not working

Hi,

I have the following:

_list_user.rhtml

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?

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.

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.