![]() | Recipe 13: Confirm delete on remove event? |
|
05 Oct 2009, 19:43
Michael H (1 post) |
Hi all, I’m using a straight forward implementation of Ryan’s dynamic add/remove functionality from Recipe 13 of the book. It’s all working well, but I’d like to add a standard confirm delete dialogue, just like how Rails normally does it. I.e. when the user clicks the “remove” link, I want him to simply confirm that he actually wants to delete the item. Otherwise, it all happens too fast and isn’t very user friendly. I tried implementing this by adding a call to the link_to_function line in the _task.html.erb file, but that didn’t work. I tried these approaches: <%= link_to_function “Remove”, ”$(this).up(’.task’).remove()”, :class => ‘delete’, :confirm => ‘Are you sure?’ %> <%= link_to_function “Remove”, ”$(this).up(’.task’).remove()”, :confirm => ‘Are you sure?’ %> Neither one works. Anybody have a good solution? Thanks! |
|
14 Dec 2009, 18:43
Anatoly Mikhaylov (6 posts) |
<%= link_to_function(“Remove”, ”if (confirm(‘Really?’)) $(this).up(’.task’).remove()”) %> |
| You must be logged in to comment |

