In my project I am calling a partial in my view
game_player_main.html.erb:
<%= button_to "Wurfbild", home_player_statistic_detail_path(:game_id => @game.id, :player_id => @player.id, :home_or_away => @home_or_away, :player_mode => 'GoalArea'), class: 'btn_submit', :remote => true %>
player_statistic_detail.js.erb:
$("#player_statistic_detail").html("<%= escape_javascript render(partial: 'home/player_statistic_detail.html.erb', :handlers => [:erb]) %>");
Everything works fine. In my partial view I have a canvas field. By clicking this field it should reload the partial passing the x- and y-coordinates of the click event.
Here is my code:
_player_statistic_detail.html.erb:
<script>
var canvas = createHiDPICanvas(350, 228);
var ctx = canvas.getContext("2d");
canvas.addEventListener("mousedown", doMouseDown, false);
function doMouseDown(event) {
canvas_x = event.pageX;
canvas_y = event.pageY;
canvas_x -= canvas.offsetLeft;
canvas_y -= canvas.offsetTop;
$("#player_statistic_detail").html("<%= escape_javascript render(partial: 'home/player_statistic_detail.html.erb', :handlers => [:erb]) %>");
}
If I just copy the javascript command into my view I am getting an error:
ActionView::Template::Error (stack level too deep)
Is it possible to refresh my partial player_statistic_detail.html.erb an d pass the coordinates?
Aucun commentaire:
Enregistrer un commentaire