gpt4 book ai didi

javascript - best_in_place nil 和 edit 函数不能在 rails4 上使用 bootstrap 应用程序

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:43:53 27 4
gpt4 key购买 nike

之前在项目中用过gem,只是rails 3,没有css框架。现在,best_in_place 的 jQuery 函数似乎被阻止或根本没有加载。 :nil 函数中没有可见的占位符,也没有可用的编辑当前值。

这是我的部分观点:

<div class="row">
<div class="col-lg-4">
<%= best_in_place [@company,service], :name, type: :input, :nil => "Click to fill" %>
</div>
<div class="col-lg-4">
<%= best_in_place [@company,service], :duration, type: :input, :nil => "Click to fill" %>
</div>
<div class="col-lg-4">
<%= link_to 'X', [@company,service], method: :delete, data: { confirm: 'Are you sure?'} %>
</div>
</div>

我的 Controller :

def update
respond_to do |format|
if @service.update(service_params)
format.html { redirect_to @service, notice: 'Service was successfully updated.' }
format.json { respond_with_bip(@service) }
else
format.html { render :edit }
format.json { render json: @service.errors, status: :unprocessable_entity }
end
end

结束

用于激活 jquery best_in_place 函数的 service.js.coffee

jQuery ->
$('.best_in_place').best_in_place()

和application.js

//= require jquery
//= require jquery_ujs
//= require jquery_nested_form
//= require turbolinks
//= require bootstrap.min
//= require jquery-ui
//= require jquery.purr
//= require best_in_place
//= require best_in_place.jquery-ui
//= require_tree

我还注意到 best_in_place 的最新更新是从 02/2013 开始的,所以它可能与我目前的项目不完全兼容。如果是这种情况,我将不胜感激任何有关类似 gem 的数据,以代替使用。

编辑:

这显然是一个 javascript 问题,但我无法弄清楚。我的浏览器控制台出现以下错误:

"undefined is not a function". 

只有它指向 jquery.js 的第 10306 行,它是空的..

最佳答案

好像你忘了添加类 .best_in_place

<div class="row">
<div class="best_in_place col-lg-4">
<%= best_in_place [@company,service], :name, type: :input, :nil => "Click to fill" %>
</div>
<div class="col-lg-4">
...........

关于javascript - best_in_place nil 和 edit 函数不能在 rails4 上使用 bootstrap 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25775738/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com