5

我正在尝试让 Turbolinks 与我的Rails 3.2应用程序一起使用,但没有成功。当我点击链接时,我仍然会在 Chrome 和 Firefox 中重新加载整页。

  1. 我已将 turbolinks gem 包含在 中,并在文件Gemfile中需要它。application.js
  2. 我应该补充一点,我运行Twitter Bootstrap 2.2.1.1,并且所有非引导/rails javascript 都被禁用。

在 Chrome 开发人员工具中,我可以看到 turbolinks.js 以及所有其他文件已加载。关于为什么 turbolinks 在我的应用程序中不活动的任何建议?

4

3 回答 3

4

如果您使用的是引导模板,则 javascript(默认情况下)不会放置在<head>您页面的元素中。

我能够使用 Rails 3.2.11、turbolinks 1.0 和默认引导模板作为我的应用程序布局重现该问题

如果你<%= javascript_include_tag "application" %>从布局的底部移动(通常就</body><head>元素的上方),那么一切都应该开始工作了。

一个。

于 2013-01-21T17:07:40.327 回答
0

If I were you I would disable bootstrap to isolate the problem first. There might be some weird problems due to that. Take a look at Yehuda Katz' blog post on Turbolinks and you'll see some of the possible problems.

However, from your post I'm unclear as to what the problem is. If it is that page-specific js isn't getting loaded, this may be because turbolinks doesn't reload :head within your rails view.

Look into calling (page:load), (page:change) as found in the Turbolinks README.md file and loading things that way? Also, with certain pages that might not be well suited to turbolinks, you can pass a data tag to disable it on that specific page.

Will

于 2013-01-17T15:22:20.647 回答
-2

就我而言,我有一件奇怪的事情:

Turbolink 与 firefox 和 safari 配合得很好;但它不是 chrome :我有一个完整的页面重新加载,由网络检查员确认。

于 2013-12-06T08:26:25.480 回答