Best in Place Editing not working with Rails 4. 可以看到字段但不能编辑
Best in Place Editing not working with Rails 4. Can see field but can't edit
我正在尝试在 rails 4.0 应用程序中实施最佳就地内联编辑。出现最佳位置字段,但我无法进行编辑。
我在表单中设置了 'traditional' 显示在最佳位置字段旁边的字段。
<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>
看起来像下面这样。我可以看到看起来像输入字段的东西。它看起来与 'traditional' 字段相同。当你点击它时,你会得到一个蓝色的框。但是,我无法编辑它。
我的 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。
在 inspect 中,我看到以下内容似乎表明 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 版本兼容。如果是这样,谁能告诉我我可能哪里出错了?
-------------------- 编辑
这是我单击最佳就地字段后显示的开发日志行。
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
我使用的是 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 的相同问题。
我正在尝试在 rails 4.0 应用程序中实施最佳就地内联编辑。出现最佳位置字段,但我无法进行编辑。
我在表单中设置了 'traditional' 显示在最佳位置字段旁边的字段。
<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>
看起来像下面这样。我可以看到看起来像输入字段的东西。它看起来与 'traditional' 字段相同。当你点击它时,你会得到一个蓝色的框。但是,我无法编辑它。
我的 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。
在 inspect 中,我看到以下内容似乎表明 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 版本兼容。如果是这样,谁能告诉我我可能哪里出错了?
-------------------- 编辑
这是我单击最佳就地字段后显示的开发日志行。
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
我使用的是 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 的相同问题。