I am trying to replicate the Delete button icon in this example using the content_tag Rails 3 method inside a nested form and unobtrusively using jQuery (or at least I hope).
Twitter-Bootstrap Delete Icon (Example)
Created by html when checking with Firebug below.
<a class="btn btn-danger" href="#"> <i class="icon-trash icon-white"></i> Delete </a>
I use the following to generate a button with an icon, but I canโt add โDelete Ingredientsโ to it, nor can I get a โ#โ for href.
Here is my code from part of the ingredients:
<%= link_to content_tag(:a, content_tag(:i, '', class: "icon-trash icon-white"), class: "btn btn-danger remove_fields") %>
This generates:
<a class="btn btn-danger remove_fields"> <i class=icon-trash icon-white"></i> </a>
This was based on information from the Api dock - content_tag
which had the following code example:
content_tag(:div, content_tag(:p, "Hello world!"), :class => "strong") # => <div class="strong"><p>Hello world!</p></div>
Can someone kindly point me in the right direction? Why am I missing the information I mentioned above?
NB I can get this to work with the link_to block, but I would like to know if it can be done on the same line without do..end and, more importantly, in the content_for method.
<%= link_to('#', class: "btn btn-danger remove_fields") do %> <i class: "icon-trash icon-white"></i> Delete <% end %>