Reddirt
Reddirt

Reputation: 5953

Rails Bootstrap close modal

I'm using a Bootstrap modal in a Rails app. I would like to close the modal in the view.

For instance Bootstrap documentation has:

<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>

I tried this:

<%= submit_tag 'Cancel', :type => :reset, :class => "btn btn-danger", :input_html => {data-dismiss="modal" aria-hidden="true"} %>

But, I get a syntax error.

I want to use the same technique to close the submit button.

I could close it in jquery, but I'd really like to close it in the form.

Thanks!

Upvotes: 3

Views: 4231

Answers (1)

MrDanA
MrDanA

Reputation: 11647

:input_html => {data-dismiss="modal" aria-hidden="true"}

Your hash is malformed. Try this:

:input_html => {"data-dismiss" => "modal", "aria-hidden" => "true"}

I believe you don't even need the :input_html and can just use the inner hash values right away, like so:

<%= submit_tag 'Cancel', :type => :reset, :class => "btn btn-danger", "data-dismiss" => "modal", "aria-hidden" => "true" %>

Upvotes: 8

Related Questions