Rails, javascript not loading after clicking through link_to helper

前端 未结 7 1058
一整个雨季
一整个雨季 2020-11-28 19:11

I\'m having some trouble loading my javascript when I use a link_to helper in rails. When I either manually enter the url with \'localhost:3000/products/new\' or reload the

相关标签:
7条回答
  • 2020-11-28 20:00

    FWIW, from the Turbolinks docs, the more appropriate event to capture instead of the $(document).ready is page:change.

    page:load has a caveat that it doesn't fire on cache reloads...

    A new body element has been loaded into the DOM. Does not fire on partial replacement or when a page is restored from cache, so as not to fire twice on the same body.

    And since Turbolinks is just switching the view, page:change is more appropriate.

    0 讨论(0)
提交回复
热议问题