That makes sense. When your page loads, the value of @deals is inserted in
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 responds
to JS. Then in your view, you can render the newly refreshed @deals. You'll
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 examples.
In your controller:
def some_update
@deals = Deal.all
end
In some_update.js.erb:
<%= escape_javascript(render(:partial => @deals)) %>
Then change your JavaScript to hit some_update and use the result of
some_update:
onPullDown: function () {
setTimeout(function () {
.ajax({
url: 'controller/some_update.js',
success: function(data) {
$('#thelist').replaceWith(data);
myScroll.refresh();
}
});
});
},
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.