Search code examples
ruby-on-railsujs

Confirm boxes not working for delete links only


I am currently banging my head against the desk trying to figure out why this is not working. I am trying to get the ujs confirmation box to show up when a delete link is clicked. Currently, the item is deleted with no confirmation box. Here is my delete link:

<%= link_to "void", project, method: :delete, data: {comfirm: "Are you sure you want to delete this project?"} %>

Here is where it gets strange. The following link (not a delete link) works as expected:

<%= link_to "About", about_path, data: {confirm: "test test"} %>

I did some digging in the gem itself and was able to discover that, with the delete link, the data-message attribute is not being parsed correctly in the following code. Specifically, the

if (!message) { return true; }

is returning true, where message is defined as follows:

message = element.data('confirm')

Note: element is the entire link itself. Can anyone help me find out why this is happening? I am using Rails 3.2 if it helps.


Solution

  • I have done this, just make it confirm instead of comfirm, and it works fine.

    <%= link_to "void", project,method: :delete, data: {confirm: "Are you sure you want to delete this project?"} %>