将设计 sign_in 表单导入 Twitter Bootstrap Modal [英] Getting devise sign_in form into Twitter Bootstrap Modal

查看:25
本文介绍了将设计 sign_in 表单导入 Twitter Bootstrap Modal的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,所以我想使用 Twitter 引导模式来显示设计登录表单.

我将维基文章的代码放在此处:https://github.com/plataformatec/devise/wiki/How-To:-Display-a-custom-sign_in-form-anywhere-in-your-app

我的应用程序布局文件中有以下标记

<div class="modal-header"><button class="close" data-dismiss="modal">×</button><h3>登录</h3>

<div class="modal-body"><%= simple_form_for(resource, :as => resource_name, :url => session_path(resource_name), :html => {:class => 'form-horizo​​ntal'}) 做 |f|%><div class="inputs"><%= f.input :email, :required =>false, :autofocus =>真%><%= f.input :password, :required =>假%><%= f.input :remember_me, :as =>:boolean 如果 devise_mapping.rememberable?%>

<div class="modal-footer"><%= f.button :submit, "登录", :class =>'btn btn-primary', :data =>{:解雇=>模态"}%><%结束%>

并且,按照 wiki 中的建议,将以下内容添加到应用程序帮助文件中

def 资源名称:用户结尾定义资源@resource ||= User.new结尾def devise_mapping@devise_mapping ||= Devise.mappings[:user]结尾

然而,它不起作用.模态消失,什么也没有发生.该页面不会去任何地方或做任何事情.转到实际登录页面有效,但提交的模态无效.建议?

解决方案

这是最终工作的代码

<%= simple_form_for(:user, :url => user_session_path) do |f|%>

Okay, so I want to use the twitter bootstrap modal to display the devise sign-in form.

I am basing my code of the wiki article here: https://github.com/plataformatec/devise/wiki/How-To:-Display-a-custom-sign_in-form-anywhere-in-your-app

I have the below markup in my application layout file

<div class="modal fade" id="loginModal">
  <div class="modal-header">
    <button class="close" data-dismiss="modal">×</button>
    <h3>Sign In</h3>
  </div>
  <div class="modal-body">
    <%= simple_form_for(resource, :as => resource_name, :url => session_path(resource_name), :html => {:class => 'form-horizontal'}) do |f| %>
          <div class="inputs">
            <%= f.input :email, :required => false, :autofocus => true %>
            <%= f.input :password, :required => false %>
            <%= f.input :remember_me, :as => :boolean if devise_mapping.rememberable? %>
          </div>
  </div>
    <div class="modal-footer">
        <%= f.button :submit, "Sign in", :class => 'btn btn-primary', :data => { :dismiss => "modal"} %>
        <% end %>
    </div>
</div>

And, following the advice in the wiki, added the following to the application helper file

def resource_name
  :user
end

def resource
  @resource ||= User.new
end

def devise_mapping
 @devise_mapping ||= Devise.mappings[:user]
end

It however, does not work. The modal dismisses and nothing happens. The page doesn't go anywhere or do anything. Going to the actual sign-in page works, but submitted the modal does not. Suggestions?

解决方案

This is the code that ended up working

<%= simple_form_for(:user, :url => user_session_path) do |f| %>

这篇关于将设计 sign_in 表单导入 Twitter Bootstrap Modal的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
其他开发最新文章
热门教程
热门工具
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆