【发布时间】:2016-10-25 03:18:44
【问题描述】:
在我的application.js 文件中,我有以下内容:
$(document).ready(function() {
/* Activating Best In Place */
jQuery(".best_in_place").best_in_place();
$('.highlight_on_success').bind("ajax:success", function(){$(this).closest('div.social-comment').effect('highlight');});
});
我正在使用Best In Place gem,它为我提供了上面的函数,可以在我的best_in_place 调用中使用。
但是,当我使用它时,我的 JS 控制台中出现此错误:
Uncaught TypeError: $(...).closest(...).effect is not a function application.self-440dd817e40548768e9.js:25
我该如何解决这个问题并让它发挥作用?
【问题讨论】:
-
effect()可能来自 jQueryUI。是否包含在页面中? -
嗯,好的。不....我没有使用 jQueryUI。我可以为 vanilla jQuery 使用什么替代方案来获得类似的效果?
-
仅当您将其编写为名为
effect()的 jQuery 插件时,因为它是从best_in_place内部调用的,我假设 -
你可以创建一个类似效果的 CSS 过渡,然后添加适当的类。
-
@Barmar 但要么必须修改原始插件以删除
effect()调用,要么编写一个具有相同名称的noop插件并在 css 中执行此操作
标签: javascript jquery ruby-on-rails asset-pipeline ruby-on-rails-5