How to render a partial from javascript with custom locals?
I do have something like this:
var begin = $("#begin_date").val();
var end = $("#end_date").val();
$("#table").html("<%= escape_javascript(render partial: 'my_partial', locals: { begin_date: begin_d, end_date: end_d}) %>")
So, I know that 'begin_d' and 'end_d' must be .erb in order to be loaded. Is there anyway to pass javascript vars in order to render a partial with custom locals values? Or any other way to achieve the same?
My intent is to refresh a table based on the dates (if they are changed).
EDIT:
I found the answer. Phlip helped pointing that I should use Ajax. So now, I made an Ajax request to a controller that simply does:
respond_to do |format|
format.html {render partial: 'my_partial', locals: {begin_date: params[:begin_date], end_date: params[:end_date]}}