【问题标题】:Best in Place Editing not working with Rails 4. Can see field but can't edit最佳就地编辑不适用于 Rails 4。可以看到字段但无法编辑
【发布时间】:2017-01-20 16:49:56
【问题描述】:

我正在尝试在 rails 4.0 应用程序中实现 Best in Place 内联编辑。出现了最佳现场,但我无法进行编辑。

我在表单中设置了“传统”显示在“最佳位置”字段旁边的字段。

<div class="field">
  <td> Sales order</td>
  <td ><span  class="text_left"><%= @bedsheet_line.sales_order %></span>
    | <%= best_in_place @bedsheet_line, :sales_order, tabindex: "1", ok_button: true %> |</td>
</div>

如下所示。我可以看到看起来像输入字段的内容。它看起来与“传统”字段相同。当你点击它时,你会得到一个蓝色的框。但是,我无法编辑它。

我的 Rails 设置是

Ruby Information    ruby 2.2.4p230 (2015-12-16 revision 53155) [i386-mingw32]
Rails Version   4.2.7.1
Rails Environment   development ( development/test/production)

gemfile 是

gem 'best_in_place', '~> 3.0.1'             # for in place editing
gem 'responders', '~> 2.0'

Application.js 是

/
//= require jquery
//= require jquery_ujs
//= require jquery.turbolinks
//= require turbolinks
//= require ckeditor/init
//= require jquery.are-you-sure
//= require script
//= require script.responsive
//= require best_in_place
//= require best_in_place.jquery-ui
//= require jquery.purr
//= require_tree .

我的控制器

if @bedsheet_line.update(bedsheet_line_params)

   # format.html { redirect_to @bedsheet_line, notice: 'Bedsheet line was successfully updated.' }
    format.html { redirect_to @prev_url, notice: 'Bedsheet line was successfully updated.' }
    #format.json { render :show, status: :ok, location: @bedsheet_line }
    format.json { respond_with_bip(@bedsheet_line) }
  else
    format.html { render :edit }
    # format.json { render json: @bedsheet_line.errors, status: :unprocessable_entity }
    format.json { respond_with_bip(@bedsheet_line) }
  end
end

我使用 chrome 的视觉事件扩展。它没有显示附加到该字段的任何 javascript/jquery。

在检查中,我看到以下内容,这似乎表明 Best in place 正在某种程度上进行交互。

<span data-bip-type="input" data-bip-attribute="sales_order" data-bip-object="bedsheet_line" data-bip-ok-button="true" data-bip-original-content="123" data-bip-url="/bedsheet_lines/3081" data-bip-value="123" class="best_in_place" id="best_in_place_bedsheet_line_3081_sales_order" tabindex="1">123</span>

我无法从文档中判断 Best In Place 是否与我正在使用的 ruby​​/rails 版本兼容。如果是的话,谁能告诉我哪里可能出错了?

--------------------- 编辑

这是在我单击 Best in place 字段后显示的开发日志行。

 Rendered C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/web-console-2.3.0/lib/web_console/templates/_inner_console_markup.html.erb within layouts/inlined_string (0.0ms)
  Rendered C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/web-console-2.3.0/lib/web_console/templates/_prompt_box_markup.html.erb within layouts/inlined_string (0.0ms)
  Rendered C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/web-console-2.3.0/lib/web_console/templates/style.css.erb within layouts/inlined_string (0.0ms)
  Rendered C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/web-console-2.3.0/lib/web_console/templates/console.js.erb within layouts/javascript (846.1ms)
  Rendered C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/web-console-2.3.0/lib/web_console/templates/main.js.erb within layouts/javascript (1.0ms)
  Rendered C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/web-console-2.3.0/lib/web_console/templates/error_page.js.erb within layouts/javascript (0.0ms)
  Rendered C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/web-console-2.3.0/lib/web_console/templates/index.html.erb (1854.2ms)


Started GET "/assets/header.jpg" for ::1 at 2017-01-20 11:57:34 -0500


Started GET "/assets/menuseparator.png" for ::1 at 2017-01-20 11:57:34 -0500


Started GET "/assets/object371718839.png" for ::1 at 2017-01-20 11:57:34 -0500


Started GET "/assets/spacer.gif" for ::1 at 2017-01-20 11:57:34 -0500

【问题讨论】:

    标签: ruby-on-rails best-in-place


    【解决方案1】:

    我使用的是过时版本的 jquery,

    我当前的版本:

    Using on_the_spot 1.0.5
    Using jquery-turbolinks 2.1.0
    Using jquery-ui-rails 6.0.1
    Using rails 4.2.7.1
    

    我将 application.html.erb 中的 jquery 链接更改为包含

    <% javascript_include_tag  "http://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js" %>
    
    <% javascript_include_tag "http://code.jquery.com/ui/1.11.4/jquery-ui.min.js"
          integrity="sha256-xNjb53/rY+WmG+4L6tTl9m6PpqknWZvRt0rO1SRnJzw="
          crossorigin="anonymous"%>
    
      <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css">
    
      <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
    
      <%= stylesheet_link_tag :on_the_spot %>
    

    我不确定 jquery 链接是否最佳,但似乎应用程序中与 Jquery 相关的所有内容都运行正常。更新 jquery 库不仅修复了 best_in_place,还修复了 on_the_spot 的相同问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-08
      • 1970-01-01
      • 1970-01-01
      • 2013-03-05
      相关资源
      最近更新 更多