47
46

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Rails5でTurbolinksの挙動が変わってた。

Last updated at Posted at 2016-07-14

今までのイベント

$(document).on 'page:before-change' , -> console.log 'page:before-change'
$(document).on 'page:fetch'         , -> console.log 'page:fetch'
$(document).on 'page:receive'       , -> console.log 'page:receive'
$(document).on 'page:change'        , -> console.log 'page:change'
$(document).on 'page:update'        , -> console.log 'page:update'
$(document).on 'page:load'          , -> console.log 'page:load'
$(document).on 'ready page:load'    , -> console.log 'ready and load'
$(document).ready                     -> console.log '$(document).ready in assets'
$(window).on 'load'                 , -> console.log '$(window).load in assets'

これでJSが発火してくれていたが、、、

Rails5でのイベント

# ページ切り替え時(初回ページも対象)
$(document).on 'turbolinks:load', -> console.log 'turbolinks:load'
# ページ切り替え時(初回ページは対象外)
$(document).on 'turbolinks:render', -> console.log 'turbolinks:render'
# ページ遷移前
$(document).on 'turbolinks:request-start', -> console.log 'turbolinks:request-start'

これで発火するように変わってた。
当面はこの二つだけ知っていれば問題ないかな。

あと、ページにキャッシュするページ数とかを設定できそうだけど、今の所はまだ未調査。
部分レンダリングすらまだ使ってない。

TurbolinksのGithubはこちら。

47
46
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
47
46

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?