How To Execute A Rails Command With Sweet Alert 2? December 03, 2022 Post a Comment I have the following sweet alert 2 message: Solution 1: Actually that is the expected behaviour. As you can see in the second screenshot, the ERB parser has generated the correct anchor tags inside your JavaScript code causing the SyntaxError. (You can't have HTML in JavaScript! Unless they are around string quote marks of course.) What you want to do is this instead: <button onclick=' Swal.fire({ title: "Select a page you want to be redirected:", showDenyButton: true, showCancelButton: true, confirmButtonText: "Home", denyButtonText: "About", }).then((result) => { /* Read more about isConfirmed, isDenied below */ if (result.isConfirmed) { location.pathname = "<%= root_path %>" } else if (result.isDenied) { location.pathname = "<%= home_about_path %>" } }); '>SHOW SWEET ALERT</button> Copy "location.pathname = x" will direct you to a relative path.Baca JugaHow To Execute A Rails Command With Sweet Alert 2?Including A Different Image In Sweetalert2 Popup Message Based On Selection Of A Div After Clicking A ButtonSweetalert2 Text Input With Validation Of The Text With Javascript In R Shiny The server's ERB parser will replace root_path and home_about_path variables with the paths you're looking for. Share You may like these postsSweetalert2 Text Input With Validation Of The Text With Javascript In R ShinySweetalert2 Text Input With Validation Of The Text With Javascript In R ShinyIncluding A Different Image In Sweetalert2 Popup Message Based On Selection Of A Div After Clicking A ButtonHow To Execute A Rails Command With Sweet Alert 2? Post a Comment for "How To Execute A Rails Command With Sweet Alert 2?"
Post a Comment for "How To Execute A Rails Command With Sweet Alert 2?"