I’m using RoR 3.1 and Twitter Bootstrap, and want to create a button that links to a controller action– the caveat being that inside of that button, I’d like to add a ‘icon-remove’ link that, when clicked, will delete the containing button.
Is this possible?
My working button:
<%= link_to exp, edit_exp_path, :class => "btn btn-inverse", :controller => :exps, :method => :edit %>
My working ‘delete’ icon:
<%= link_to "", exp_path(exp.id), :class => "icon-remove", :confirm => "Are you sure?", :controller => :exps, :method => :delete %>
How do I put my delete icon inside of the button?
Edit: To be clear, I want to retain both actions with the button. Clicking on button text should link to ‘edit’ controller action, while clicking the ‘x’ provided by Bootstrap’s ‘icon-remove’ class should delete the button.
You should use a button group: http://twitter.github.com/bootstrap/components.html#buttonGroups
The button on the left would be your normal button, and on the right, you can have your
X.It would make more sense to users I think, and would minimize the number of misclicks.