Attempting to customize my submit_tag
confirmation popup within my Rails view, I encounter an issue when trying to utilize an instance variable from the Rails controller. Within the controller, I set up the variable as follows:
@confirmation_msg = "test"
Subsequently, in my .haml
view file, I attempt to incorporate this variable as the text for the confirmation prompt inside the submit_tag
.
= submit_tag "Increase Limits", { onclick: "return confirm(#{@confirmation_msg})", class: "btn btn-danger"}
However, upon executing this code, the confirmation prompt displays blank without any visible text. Notably, the cancel and OK buttons are still present. Surprisingly, if I replace
"return confirm(#{@confirmation_msg})"
with "return confirm('test')"
, the prompt successfully shows "test". What could be causing the variable from the controller to render as empty text in the confirmation prompt?