I am trying to use bootstrap modal http://twitter.github.com/bootstrap/javascript.html#modals on a rails link to open that link in the modal
<%= link_to page_path, target: '_blank' %>
but somehow it is not working. The standard toggle code is –
<a data-toggle="modal" href="#myModal" class="btn">Launch demo modal</a>
but I am not sure how to apply it to link_to in rails, any help ?
Thanks
Best Answer
Below is the code if you want to preload the modal on the page in hidden state
And if you want to load the modal through ajax then you can do something like this
In
posts/new.js.erb
you would includeMake sure that you have a unique id or class for every modal body.
Assuming you want to create a new post using modal form, the controller code and
_form.html.erb
is in place