3

In a rails project I am using the cocoon gem to create a nested form. In the provided example, the method link_to_remove_association is used, generating a link which deletes the current nested form when clicked.

This works fine as a link, but I wish to have the same functionality in a nested bootstrap button. Is this possible?

The best I have so far (which only inserts a link within the button):

%span.input-group-btn
    %button.btn.btn-default.btn-lg{type: 'button'}
      = link_to_remove_association "X", f, type:'button'
user1618840
  • 453
  • 1
  • 5
  • 14

2 Answers2

2

Instead of nesting a button, you can just apply the button-classes to style the link directly:

%span.input-group-btn
  = link_to_remove_association "X", f, class: 'btn btn-default btn-lg'
nathanvda
  • 49,707
  • 13
  • 117
  • 139
1

This is what I used to accomplish this.

<%= link_to_remove_association button_tag('x', type: "button", class: "close"), f %>