【问题标题】:Changing Devise for Bootstrap modal更改 Bootstrap 模式的设计
【发布时间】:2012-06-13 08:29:04
【问题描述】:

我找到了这个链接Link to another page using Twitter Bootstrap jquery modal in rails,这完全是我需要的——注册和其他使用 Bootstrap modal 和 Devise。

我做了这些步骤,但它没有弹出,而是将我重定向到另一个页面并显示不正确的页面。

它的行为真的很奇怪,它打开了 NOT MINE 表单。

_new.html.erb

<div class="modal hide fade in" id="sign_up">

<%= form_for resource, :as => resource_name, :url => registration_path(resource_name),do |f| %>
  <%= devise_error_messages! %>
....
 <% end %>     

创建新的.js.erb:

      $("#main").before("<%= escape_javascript(render "new", :formats => [:html]) %>");
      $("#sign_up").modal();

和链接到:

       <%= link_to "Sign up", new_user_registration_path, :remote => true %>

在 application.html.erb 中:

    <%= stylesheet_link_tag    "application", media: "all" %>
   <%= javascript_include_tag 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js' %>
    <%= csrf_meta_tags %>

已编辑。 在我的日志中: 由 Devise::RegistrationsController#new as JS 处理 渲染设计/注册/new.js.erb (15.6ms) 在 31 毫秒内完成 500 个内部服务器错误

      ActionView::Template::Error (Missing partial devise/new with {:locale=>[:en], :f
       ormats=>[:js, :html], :handlers=>[:erb, :builder, :coffee, :rabl]}. Searched in:

     * "D:/print_it_green/app/views"
    * "C:/Ruby192/lib/ruby/gems/1.9.1/gems/devise-2.1.0/app/views"
       ):
        1: $("#sign_up").before("<%= escape_javascript(render "devise/new", :formats
       => [:html]) %>");
         2: $("#sign_up").modal();
      app/views/devise/registrations/new.js.erb:1:in `_app_views_devise_registration
       s_new_js_erb___312569811_25856784'

问题出在哪里?

【问题讨论】:

    标签: ruby-on-rails ajax twitter-bootstrap modal-dialog


    【解决方案1】:

    new.js.erb 中,您尝试在名为 #main 的部分中注入模式代码。

    将带有id=main 的空&lt;div&gt; 标记添加到您从中调用它的页面,它应该可以工作。

    【讨论】:

      【解决方案2】:

      您的文件在哪个文件夹中?如果你打算使用 Devise,那么你可以使用 rails generate devise:views 来自定义视图。然后将您的 new partial 和 new js 文件放入该文件夹中。

      如果需要,您也可以configure the controller,但如果您创建视图,则 Devise 应自动指向上述命令创建的 Devise 文件夹。

      在您的 jQuery 中,您应该输入 render "devise/registrations/new" 而不仅仅是 "new"

      【讨论】:

      • 在设计文件夹中。我生成了它们。一会儿,我试试看。
      • 你的服务器说什么?它应该说“由 Devise::RegistrationsController#new as JS 处理”。
      猜你喜欢
      • 1970-01-01
      • 2019-05-22
      • 1970-01-01
      • 1970-01-01
      • 2012-05-09
      • 1970-01-01
      • 2016-08-25
      • 2012-05-19
      • 1970-01-01
      相关资源
      最近更新 更多