Reputation: 33
I am trying to create what I thought was a simple modal login window in rails using foundation. Unfortunately it isn't as easy I thought.
Basically what I am trying to do is provide a link to the user on the main page that when they click, will display the devise signup form in a modal window.
Can someone help me out? Thanks!
Upvotes: 3
Views: 2825
Reputation: 1045
Foundation Js Reveal also support ajax content part.
<a href="http://controller-action" data-reveal-id="myModal" data-reveal-ajax="true">new action link</a>
<a href="http://controller-action2" data-reveal-id="myModal" data-reveal-ajax="true">edit action link</a>
In controller-action , render ajax content with layout: false
def controller-action
@xy = @x.y.new
render :layout => false
end
In controller-action view, add your form and close button;
<a class="close-reveal-modal">×</a>
<%= form_for(@xy, url: "/create-action", :method=>'post') do |f| %>
<%= f.text_field :name , placeholder: '....' %>
<%= f.submit 'Save', class: 'button tiny right', data: { disable_with: "wait..." } %>
<% end %>
Upvotes: 0
Reputation: 1511
Here is an example of how you would do it foundation
<%= link_to "Sign Up", '#', data: {:'reveal-id' => 'signupModal'} %>
<div id="signupModal" class="reveal-modal">
<%= render 'devise/registrations/new' %>
<a class="close-reveal-modal">×</a>
</div>
You have to rename the devise/registrations/new
to devise/registrations/_new
to make it a partial.
You can find the full set of options and documentation in the foundation docs on reveal
Upvotes: 7