Rails Bootstrap confirm delete using Sweetalert -
i trying replace "confirm" delete sweetalert.
this works fine delete observer normal alert dialog. i'm not sure how call sweetalert.js.
sorry if dumb question. i'm pretty new this! thanks!
team.html.erb
<td> <div class="btn-group"> <%= link_to "/members/observers/#{observation.id}", class: "btn btn-xs btn-danger", method: :delete, data: { confirm: "are sure?" } %> <i class="fa fa-times fa-fw" data-toggle="tooltip" data-placement="top" title="remove observer"></i> <% end %> </div> </td>
sweetalert.js
swal({ title: "are sure?", text: "you not able recover imaginary file!", type: "warning", showcancelbutton: true, confirmbuttonclass: "btn-danger", confirmbuttontext: "yes, delete it!", cancelbuttontext: "no, cancel plx!", closeonconfirm: false, closeoncancel: false }, function(isconfirm) { if (isconfirm) { swal("deleted!", "your imaginary file has been deleted.", "success"); } else { swal("cancelled", "your imaginary file safe :)", "error"); } });
make sure jquery
, jquery_ujs
included in application.js
file.
//= require jquery //= require jquery_ujs
and install 'jquery-rails'
gem if didn't yet.
gem 'jquery-rails'
then run bundle install
i believe you're go! :)
Comments
Post a Comment