1

I have a partial that renders on my home page, and it displays fields from an instance variable, @matchup (e.g. @matchup.num_votes). When the matchup is clicked, a jQuery event-handler makes an AJAX request to the server that updates the value of fields on @matchup, and then updates the value of @matchup by pulling a Matchup object at random.

How can I make these changes (the new value of @matchup) reflect in the view without refreshing the whole page?

1
  • Could you break down your desired behaviour into steps? Finding it difficult to understand what you're trying to do. Commented Oct 4, 2013 at 17:37

1 Answer 1

2

the you can update the HTML of the object through *.js.erb. You need the ID of DOM element which inner HTML you want to update. If the ID of the DOM is "match_up":

$("#match_up").html('<%= escape_javascript(name of partial file which contain new html)) %>');
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks, can I use .js.erb with coffeescript? .js.coffee.erb?
you will got your answer here link

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.