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 () {
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.