Jquery rails ajax

so I am using jquery and updating a dom element with

$(’#thelist’).replaceWith("<%= escape_javascript(render(:partial =>
@deals)) %>");

this works fine except it is not hitting the server so if @deals is
updated, it is not refreshing and showing the latest version. My
question is how to ajax this thing so that it will update to the
latest version of @deals. The full code is:
onPullDown: function () {
setTimeout(function () {


escape_javascript(render(:partial => @deals)) %>");

thanks in advance!

That makes sense. When your page loads, the value of @deals is inserted
the JavaScript that is sent to the client. As you noticed, since your
JavaScript code never makes a request back to the server, it just keeps
calling replaceWith on the value of the original @deals.

The easiest way is probably to have some type of update action that
to JS. Then in your view, you can render the newly refreshed @deals.
also need to update your JavaScript to hit this action on the server and
update your DOM element with the result. Here are some rough code

In your controller:

def some_update
@deals = Deal.all

In some_update.js.erb:

<%= escape_javascript(render(:partial => @deals)) %>

Then change your JavaScript to hit some_update and use the result of

onPullDown: function () {
setTimeout(function () {
url: ‘controller/some_update.js’,
success: function(data) {