简体   繁体   English

Rails Devise Bootstrap注册模式

[英]Rails Devise Bootstrap Sign Up modal

I'm trying to alter my devise registration view file to work with bootstrap modals. 我正在尝试更改我的设计注册视图文件以使用引导程序模态。

I have followed the bootstrap instructions and slotted the form into the modal and linked it to the navbar menu. 我已按照引导程序说明进行操作,并将表单插入了模式列表,并将其链接到导航栏菜单。 Now, when i click on 'Register' in my navbar. 现在,当我单击导航栏中的“注册”时。 Nothing happens. 什么都没发生。 The form doesn't go anywhere. 该表格没有任何地方。 I had this working when it was just a standard page view. 当它只是一个标准页面视图时,我就可以使用它。 Can anyone help? 有人可以帮忙吗? Thank you. 谢谢。

I am trying to follow this answer but am getting confused: Twitter Bootstrap Modal not popping up for user login 我正在尝试遵循此答案,但感到困惑: Twitter引导模态未弹出用于用户登录

I have: 我有:

views/devise/shared/registration_items: 视图/设计/共享/ registration_items:

<% if user_signed_in? %>
  <li>
  <%= link_to('Edit registration', edit_user_registration_path) %>
  </li>
<% else %>
  <li>
  <%= link_to 'Register', new_user_registration_path, :remote => true, 'data-toggle' => "modal", 'data-target' => "#myModal", :method: 'get' %>
    </li>
<% end %>

views/devise/registrations/new 视图/设计/注册/新

<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title" id="myModalLabel">Sign up</h4>
      </div>
      <div class="modal-body">
           <%= simple_form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
             <%= f.error_notification %>

             <div class="form-inputs">
               <%= f.input :first_name, required: true, autofocus: true %>
               <%= f.input :last_name, required: true, autofocus: true %>
               <%= f.input :email, required: true, autofocus: true %>
               <%= f.input :password, required: true %>
               <%= f.input :password_confirmation, required: true %>


                  </div>

      </div>
      <div class="modal-footer">
        <div class="form-actions">
              <%= f.button :submit, "Sign up" %>
            </div>
        <% end %>
        <%= render "devise/shared/links" %>


      </div>
    </div>
  </div>
</div>

respond_to do |format|
  format.js
end

I get a syntax error (syntax error, unexpected ':', expecting =>) on this line: 我在此行上收到语法错误(语法错误,意外的“:”,期望=>):

  <%= render 'devise/shared/registration_items' %>

Please can anyone help. 任何人都可以帮忙。 Thank you. 谢谢。

There is a syntax error. 存在语法错误。 Change to :method => 'get' or method: 'get' in the line below 在下面的行中更改为:method => 'get'method: 'get'

'data-toggle' => "modal", 'data-target' => "#myModal", :method: 'get'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM