I am sending a remote form via submit.rails when a user clicks a checkbox in my app which works great. Now there is a value inside a div that would need to get refreshed immediately after the form was sent. After researching a bit how to realise this, I came to this solution inside my jquery function:
$( "input#my-checkbox" ).click(function() {
$(this.form).trigger('submit.rails');
$("#count-items").load();
});
this doesn't work because the load() function requires something to load e.g. a specific view. I cannot load a view into my div so I created a partial but that would not render correctly. There must be a much more simple way to refresh what is inside my div.
<div id="count-items"><%= render "pages/count_items" %></div>
The above also does not work as explained. The partial would not render here on load().
How could I simply reload the div content (foo) which would look like this:
<div id="count-items"><%= foo %></div>
after I hit my checkbox (click event) from the above code?
update.js.erb, `$('#count-items').html("<%= foo %>");