0

Hi Currently i am working on a rails project . where i have to reload a partial page .

For example Create action

 def create
    # Some transaction to the database 
   respond_to do |format|
     format.html {render :text => 'Add post' }
     format.js
   end
  end

In my views posts/create.js.rjs i would like to reload the users/_login.html.erb file This contains the total number of posts or the post's size , when it creates a new post its should reload the partial page _login.html.erb and display the posts incremented size

In create.js.rjs if i use page.reload it reloads the entire page , How to reload only the partial file _login.html.erb inside create.js.rjs .

2 Answers 2

5

The code will look like:

  page.replace_html "login-block-id", :partial => "users/login"

Where login-block-id is the id of element that wraps your login template

Note that replace_html can accept the same arguments as render do.

Sign up to request clarification or add additional context in comments.

Comments

2

Yo could also try

page[:my_div].replace :partial => "/users/login"  

where my_div is the id of element that wraps your login template

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.