<bdo id='eSatb'></bdo><ul id='eSatb'></ul>

      1. <tfoot id='eSatb'></tfoot>
      2. <legend id='eSatb'><style id='eSatb'><dir id='eSatb'><q id='eSatb'></q></dir></style></legend>

        <small id='eSatb'></small><noframes id='eSatb'>

      3. <i id='eSatb'><tr id='eSatb'><dt id='eSatb'><q id='eSatb'><span id='eSatb'><b id='eSatb'><form id='eSatb'><ins id='eSatb'></ins><ul id='eSatb'></ul><sub id='eSatb'></sub></form><legend id='eSatb'></legend><bdo id='eSatb'><pre id='eSatb'><center id='eSatb'></center></pre></bdo></b><th id='eSatb'></th></span></q></dt></tr></i><div id='eSatb'><tfoot id='eSatb'></tfoot><dl id='eSatb'><fieldset id='eSatb'></fieldset></dl></div>
      4. Twitter Bootstrap Modal没有弹出用户登录

        Twitter Bootstrap Modal not popping up for user login(Twitter Bootstrap Modal没有弹出用户登录)
          <tbody id='xKtBT'></tbody>

        • <i id='xKtBT'><tr id='xKtBT'><dt id='xKtBT'><q id='xKtBT'><span id='xKtBT'><b id='xKtBT'><form id='xKtBT'><ins id='xKtBT'></ins><ul id='xKtBT'></ul><sub id='xKtBT'></sub></form><legend id='xKtBT'></legend><bdo id='xKtBT'><pre id='xKtBT'><center id='xKtBT'></center></pre></bdo></b><th id='xKtBT'></th></span></q></dt></tr></i><div id='xKtBT'><tfoot id='xKtBT'></tfoot><dl id='xKtBT'><fieldset id='xKtBT'></fieldset></dl></div>

              <bdo id='xKtBT'></bdo><ul id='xKtBT'></ul>
              <legend id='xKtBT'><style id='xKtBT'><dir id='xKtBT'><q id='xKtBT'></q></dir></style></legend>

                <small id='xKtBT'></small><noframes id='xKtBT'>

                1. <tfoot id='xKtBT'></tfoot>
                  本文介绍了Twitter Bootstrap Modal没有弹出用户登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  当用户登陆我们的主页时,我无法将 twitter 引导弹出模式与设计登录/注册结合起来.我花了一些时间实施不同的方法,但仍然没有成功.截至目前,当我点击与模式关联的登录"按钮时,网站刷新但没有模式.

                  apps/views/layout/_header.html.slim(我的 application.erb 文件在其他部分调用)

                  li= link_to "登录", "数据切换" =>模态",数据目标"=>"#login_modal", :class =>btn btn-小"李= link_to "免费注册", "data-toggle" =>模态",数据目标"=>"#sign_up_modal", :class =>btn btn-小"

                  我有两个几乎相同的部分(sign_up_modal、login_modal)...

                  <div class="modal 隐藏淡入" id="sign_up"><div class="modal-header"><button class="close" data-dismiss="modal">x</button><h2>注册</h2></div><div class="modal-body"><%= form_for(resource, :as => resource_name, :url =>registration_path(resource_name)) 做 |f|%><%= devise_error_messages!%><div><%= f.label :email %><br/><%= f.email_field :email, :autofocus =>true %></div>

                  <%= f.label :password %><br/><%= f.password_field :password %></div>

                  <%= f.label :password_confirmation %><br/><%= f.password_field :password_confirmation %></div></div><div class="模态页脚"><p>

                  <%= f.submit "注册", :class =>'btn btn-small btn-成功' %></div></p><p><a href="#" class="btn btn-small" data-dismiss="modal">关闭</a></p></div><%结束%></div>

                  在我的 application.coffee 中,我确保需要 twitter/bootstrap

                  #= 需要 twitter/bootstrap

                  我已经确保将 gem 添加到我的 gemfile 中

                  gem "twitter-bootstrap-rails"

                  当我点击注册"或登录"时,页面会刷新.我相信我已经添加了所有代码,抱歉堆栈溢出!

                  apps/controllers/sessions_controller.rb

                  类 SessionsController <应用控制器定义新结尾定义创建用户 = User.from_omniauth(env["omniauth.auth"])session[:user_id] = user.id重定向到根路径结尾定义破坏会话[:user_id] = nil重定向到根路径结尾结尾

                  解决方案

                  在应该触发模态的按钮上执行此操作

                  <%= link_to "login", new_user_session_path, :remote =>真,数据切换"=>'模态','数据目标' =>'#your_modal_id', :class =>"btn btn-primary", :method: 'get' %>

                  为此,您必须覆盖设计 sessions #newregistrations #new 以响应 ajax 请求.你可以通过在这两个动作上引入一个 respond_to 块来做到这一点

                  respond_to do |格式|格式.js结尾

                  然后在您的 app/views/devise/registrationsapp/views/devise/sessions 中创建 new.js.erb 文件.您可以从模式中删除登录和注册表单,然后将 javascript 用于在这些 new.js.erb 文件中的模式中呈现表单.

                  您可以从模式中删除表单,并在 modal-body 中放置一个加载 gif.您可以改为将表单放在一个部分中,并将其放在 app/views/devise/sessions/_login_form.html.erb 中.然后在 app/views/devise/sessions/new.js.erb 你做这样的事情.

                  $('#your_modal_id').remove-data$('.modal-header').html ("<%= escape_javascript(render'/path/to/partial/with/header/content') %>");$('.modal-body').html ("<%= escape_javascript(render '/path/to/partial')) %>");$('.modal-footer').html ("<%= escape_javascript(render '/path/to/partial')) %>");

                  I'm having trouble incorporating a twitter bootstrap pop-over modal with devise login/signup for when a user lands on our home page. I've spent some time implementing different methods but still no success. As of right now, when I click on the "login" button that is associated with the modal, the site refreshes but there is no modal.

                  apps/views/layout/_header.html.slim (my application.erb file calls in other partials)

                  li
                    = link_to "Login", "data-toggle" => "modal", "data-target" => "#login_modal", :class => "btn btn-small"
                  
                  li
                    = link_to "Sign Up Free", "data-toggle" => "modal", "data-target" => "#sign_up_modal", :class => "btn btn-small"
                  

                  I have two partials (sign_up_modal, login_modal) that are almost identical...

                  <div class="modal hide fade in" id="sign_up">
                  <div class="modal-header">
                      <button class="close" data-dismiss="modal">x</button>
                      <h2>Sign Up</h2>
                  </div>
                      <div class="modal-body">
                          <%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
                          <%= devise_error_messages! %>
                      <div><%= f.label :email %><br />
                          <%= f.email_field :email, :autofocus => true %></div>
                      <div>
                          <%= f.label :password %><br />
                          <%= f.password_field :password %>
                      </div>
                      <div>
                      <%= f.label :password_confirmation %><br />
                      <%= f.password_field :password_confirmation %>
                      </div>
                      </div>
                      <div class="modal-footer">
                          <p>
                              <div>
                                  <%= f.submit "Sign up", :class => 'btn btn-small btn-success' %>
                              </div>
                          </p>
                          <p>
                              <a href="#" class="btn btn-small" data-dismiss="modal">Close</a>
                          </p>
                  </div>
                  <% end %>
                  </div>
                  

                  In my application.coffee I've made sure to require twitter/bootstrap

                  #= require twitter/bootstrap
                  

                  And I've made sure to add the gem to my gemfile

                  gem "twitter-bootstrap-rails"
                  

                  When I click on either "sign up" or "login" the page just refreshes..I believe I've added all my code, sorry new to stack overflow!

                  apps/controllers/sessions_controller.rb

                  class SessionsController < ApplicationController
                  
                  def new
                  
                  end
                  
                  def create
                    user = User.from_omniauth(env["omniauth.auth"])
                    session[:user_id] = user.id
                    redirect_to root_path
                  end
                  
                  def destroy
                   session[:user_id] = nil
                   redirect_to root_path
                  end
                  
                  end
                  

                  解决方案

                  Do this on the button that is supposed to trigger the modal

                  <%= link_to "login", new_user_session_path, :remote => true, 'data-toggle' => 'modal', 'data-target' => '#your_modal_id', :class => "btn btn-primary", :method: 'get' %>
                  

                  For this to work you will have to overwrite devise sessions #new and registrations #new to respond to ajax requests. you can do this by introducing a respond_to block on both of these actions like this

                  respond_to do |format|
                    format.js
                  end
                  

                  then in your app/views/devise/registrations and app/views/devise/sessions create new.js.erb files. You can remove the login and sign-up forms from the modal and put the javascript to render the forms inside the modals in these new.js.erb files.

                  You can remove the form from the modal and in modal-body you put a loading gif. You can instead put the form in a partial and place it in app/views/devise/sessions/_login_form.html.erb. Then in app/views/devise/sessions/new.js.erb you do something like this.

                  $('#your_modal_id').remove-data
                  $('.modal-header').html ("<%= escape_javascript(render'/path/to/partial/with/header/content') %>");
                  $('.modal-body').html ("<%= escape_javascript(render '/path/to/partial')) %>");
                  $('.modal-footer').html ("<%= escape_javascript(render '/path/to/partial')) %>");
                  

                  这篇关于Twitter Bootstrap Modal没有弹出用户登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  What are valid deviceNames for Chrome emulation testing with Protractor?(使用 Protractor 进行 Chrome 模拟测试的有效设备名称是什么?)
                  Protractor Check if Element Does Not Exist(量角器检查元素是否不存在)
                  Protractor e2e Tests Login Redirection(Protractor e2e 测试登录重定向)
                  Explain about async/ await in Protractor(解释 Protractor 中的 async/await)
                  Protractor browser.wait doesn#39;t wait(量角器 browser.wait 不等待)
                  How to use Protractor with Angular 2?(如何在 Angular 2 中使用量角器?)
                  • <bdo id='hx4IL'></bdo><ul id='hx4IL'></ul>

                      <tbody id='hx4IL'></tbody>
                  • <legend id='hx4IL'><style id='hx4IL'><dir id='hx4IL'><q id='hx4IL'></q></dir></style></legend>
                        <i id='hx4IL'><tr id='hx4IL'><dt id='hx4IL'><q id='hx4IL'><span id='hx4IL'><b id='hx4IL'><form id='hx4IL'><ins id='hx4IL'></ins><ul id='hx4IL'></ul><sub id='hx4IL'></sub></form><legend id='hx4IL'></legend><bdo id='hx4IL'><pre id='hx4IL'><center id='hx4IL'></center></pre></bdo></b><th id='hx4IL'></th></span></q></dt></tr></i><div id='hx4IL'><tfoot id='hx4IL'></tfoot><dl id='hx4IL'><fieldset id='hx4IL'></fieldset></dl></div>
                        <tfoot id='hx4IL'></tfoot>

                            <small id='hx4IL'></small><noframes id='hx4IL'>