3

To delete a record in rails I am using this code

<%= link_to "close #{user.name}'s light", light_path(id: light), method: :delete, data: { confirm: 'Are you sure?' } %>

result of which, I get dialog box like this enter image description here

But I wants this dialog box to look like this enter image description here

Is there any way to customize the default view of confirm dialog box?

3
  • 1
    You cannot actually chenge default look and behaviour of alert or confirm box. You need to use custom jquery plugins Oct 23, 2017 at 6:52
  • @DeepakMahakale Do you have any suggestion of custom jquery plugins to use? Oct 23, 2017 at 7:08
  • Maybe this question can point you in the right direction Oct 23, 2017 at 7:19

1 Answer 1

5

You can make use of bootstrap modal dialog box, like this:

<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
    <h4

 class="modal-title" id="myModalLabel">Delete Confirmation</h4>
      </div>
      <div class="modal-body">
        Are you sure about closing Ellen's lightbox..
        <%= link_to "Yes", light_path(id: light), method: :delete %>/
        <%= link_to "No", "javascript:void(0)",'data-dismiss': "modal" %>
      </div>
    </div>
  </div>
</div>

And change your initial link to:

<%= link_to "close #{user.name}'s light", "javascript:void(0)", 'data-target': "#myModal", 'data-toggle': "modal" %>

I hope this might be helpful to you.

1
  • @AmulyaTanksale If you have find my answer helpful you may also upvote it. I am glad to be helpful :)
    – Vishal
    Oct 24, 2017 at 5:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.