Reputation: 866
I'm using a Javascript call to dynamically remove a field from a form. My problem is that the action happens very quickly, and it's not reversible. So I'd like to add the standard Rails delete confirmation, but I can't figure out how to make it work. Basically, I want to add this ... :confirm => ‘Are you sure?’
Here's the line of Javascript responsible for removing the field:
<%= link_to_function “Remove”, ”$(this).up(’.task’).remove()” %>
This is from a standard implementation of the Ryan Bates multi-model form technique from Advanced Rails Recipes.
I can provide more details if needed.
Upvotes: 0
Views: 610
Reputation: 24105
I don't think the :confirm
option is available on link_to_function
is it?
Try adding it yourself:
<%= link_to_function "Remove",
"if(confirm('Are you sure?')) $(this).up('.task').remove()" %>
Upvotes: 1