LoginSignup
0
0

More than 1 year has passed since last update.

リンクタグでページに遷移してもreloadしないとJavaScriptのイベントが発火しない

Posted at

解決したい問題

<link_to>や<a>タグでページに遷移してもreloadしないとJavaScriptのイベントが発火しない

エラーの仮説

turbolinksが邪魔してそう...

turbolinksってなんだっけ?

turbolinksとは、ページ遷移をAjaxに置き換え、JavaScriptやCSSのパースを省略することで高速化するgem。Rails4からはデフォルト。

原因

data-turbolinkが働いて遷移したページではイベントが発火しない事があるらしい.

解決策

link_toにはdata: {"turbolinks"=>false}を追加

<a>タグには data-turbolinks="false"を追加

data-turbolinkをオフにするために、遷移元のリンクタグにdata属性を追加!

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0