Episodes
Tiago Ameller PRO said almost 3 years ago on SweetAlerts in Rails 6 :
Hi, Dave. In my RoR 5 apps, I use this code (from StackOverflow, I guess :D) ``` $.rails.showConfirmationDialog = function (link) { const message = link.data('confirm') return swal( { title: message, type: 'warning', showCancelButton: true, reverseButtons: true } ).then(function (result) { if (result.value) { return $.rails.confirmed(link) } }) } ``` As you can see `return $.rails.confirmed(link)` makes the job. It works also with TurboLinks. I don't know if this code should work with RoR 6.

David Kimura PRO said almost 3 years ago on SweetAlerts in Rails 6 :
Yea, it's really strange. On Rails 6, changing it remove the jQuery dependency, it doesn't work. I updated your code to ``` Rails.showConfirmationDialog = function (link) { const message = link.data('confirm') return swal.fire( { title: message, type: 'warning', showCancelButton: true, reverseButtons: true } ).then(function (result) { if (result.value) { return Rails.confirmed(link) } }) } ``` and the javascript alert fires, but the SweetAlert doesn't. It has to be something with the `showConfirmationDialog` not getting set or fired properly.

David Kimura PRO said almost 3 years ago on SweetAlerts in Rails 6 :
And, changing the original code with your confirmed element instead of removing the data attribute doesn't work either. It's really strange. `Rails.confirmed(element)`

Tiago Ameller PRO said almost 3 years ago on SweetAlerts in Rails 6 :
Interesting. Despite your approach is weird, is good to have a solution for when I upgrade my app to v6. I need to enhance my js skills before upgrading ;-)

nickstoneman said over 2 years ago on SweetAlerts in Rails 6 :
This was really helpful and worked without issue. It's nice to have a current tutorial for Rails 6 and Webpack. Thanks :-) Two questions to take this further: 1) How can one distinguish between multiple data confirms on the same page? 2) How can this be made page specific?

geomcn11 said about 2 years ago on SweetAlerts in Rails 6 :
Hi thanks for the video, it worked perfectly! 
I was just wondering if there is a way of having a success notification after an item is successfully edited  saying "item edited successfully" when it returns to the item page. 
Thanks again.

Simon Kiteley PRO said 2 months ago on SweetAlerts in Rails 6 :
Anyone had any luck with sweet alerts and Turbo?

Login to Comment