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?

jackerman09
  • 2,492
  • 5
  • 29
  • 46
  • Could you break down your desired behaviour into steps? Finding it difficult to understand what you're trying to do. – Damien Roche Oct 04 '13 at 17:37

1 Answers1

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)) %>');
Alexander Vogt
  • 17,879
  • 13
  • 52
  • 68
Nitin Jain
  • 3,053
  • 2
  • 24
  • 36