Pass boolean from rails controller to javascript for use in conditional
I have a form in bootstrap module which is processed with ajax. If the form validates, it closes the modal or shows validation errors as expected. However, I would like to redirect the user after the animation of the modal to hide if the condition is met based on the boolean stored in the controller. Although the condition does not work as written, it allows you to see what I am trying to accomplish:
$(document).ready(function() {
$('#modal-window').modal({remote: true});
$('#modal-window').modal('show');
$('#modal-window').on('hidden', function(){
var saved = <%= @bool %>;
if(saved == "true"){
$(window.location.replace("<%= some_url %>"));}
});
})
+3
source to share
3 answers