Jquery Rails 3.2.1中的最佳位置不是函数错误
我正在为我的Rails 3.2.1应用程序使用最好的gem。我的发展没有错误。当我试图在生产环境中运行应用程序时,我遇到了一个脚本错误Jquery Rails 3.2.1中的最佳位置不是函数错误,jquery,ruby-on-rails-3,rubygems,inplace-editing,best-in-place,Jquery,Ruby On Rails 3,Rubygems,Inplace Editing,Best In Place,我正在为我的Rails 3.2.1应用程序使用最好的gem。我的发展没有错误。当我试图在生产环境中运行应用程序时,我遇到了一个脚本错误 $(".best_in_place").best_in_place is not a function in my browser. 在我的视图页面中,我有以下代码 <%= stylesheet_link_tag "best_inplace", "jquery-ui-1.8.20.custom" %> <%= javascript_inclu
$(".best_in_place").best_in_place is not a function in my browser.
在我的视图页面中,我有以下代码
<%= stylesheet_link_tag "best_inplace", "jquery-ui-1.8.20.custom" %>
<%= javascript_include_tag "application", "jquery.dataTables.min" %>
<%= best_in_place @user, :description, :type => :textarea %>
<script>
jQuery(".best_in_place").best_in_place();
</script>
:text区域%>
jQuery(“.best_in_place”).best_in_place();
我在几分钟前也遇到了这个问题,通过将要求最佳位置
移到最后解决了这个问题,其他位置将不起作用。很奇怪,但还是管用
这是application.js
清单
//= require jquery
//= require jquery_ujs
//= require jquery.purr
//= require_tree .
//= require i18n
//= require i18n/translations
//= require best_in_place
$(document).ready(function() {
$('.best_in_place').best_in_place();
})
问题是函数
best_in_place()?
在best_in_pace.js
中声明,在执行application.js
调用best_in_place()
中的代码时,可能仍需要加载该函数。正确的解决方案是通过连接实现js文件的连接。这可以通过包括
config.assets.debug = false
和/或删除
config.assets.debug = true
在config/environments/development.rb
respconfig/environments/production.rb
。那么,
包含
best_in_pace.js
的位置并不重要(只要它位于jquery.js
之后,在调用best_in_place()
的代码之前)。样式表链接标签best_in place
缺少下划线\u place
否…正确。这是我正在使用的样式表。您需要向我们展示您的application.js。这里的问题是,“为什么我的页面中没有best\u in\u place
呢?”是的,这是真的,我之前也遇到过这种情况。