Skip to content
This repository has been archived by the owner on Jul 28, 2018. It is now read-only.

Add ability to re-run scripts on back/forward navigation #509

Merged
merged 1 commit into from
Apr 18, 2015

Conversation

Thibaut
Copy link
Collaborator

@Thibaut Thibaut commented Apr 18, 2015

… by specifying data-turbolinks-eval=true on the <script> tag.

Fix #507.

cc @reed @kevinhughes27

@kevinhughes27
Copy link

👍

@reed
Copy link
Collaborator

reed commented Apr 18, 2015

I'm on board with the functionality, but I'm not sure about the name of the attribute. Seems strange that data-turbolinks-eval=true and data-turbolinks-eval=false don't mean opposite things. Plus, I think it's always been implied that any script tag without a data-turbolinks-eval=false attribute meant that data-turbolinks-eval=true.

Off the top of my head, some alternative names could be data-turbolinks-cache-eval, data-turbolinks-history-eval, data-turbolinks-re-eval, or data-turbolinks-always-eval. Or any other name you think might be better.

@Thibaut
Copy link
Collaborator Author

Thibaut commented Apr 18, 2015

How about data-turbolinks-eval=always?

@reed
Copy link
Collaborator

reed commented Apr 18, 2015

That would work.

...by specifying data-turbolinks-eval=always on the <script> tag.
@Thibaut
Copy link
Collaborator Author

Thibaut commented Apr 18, 2015

Updated 👍

reed added a commit that referenced this pull request Apr 18, 2015
Add ability to re-run scripts on back/forward navigation
@reed reed merged commit 251821e into turbolinks:master Apr 18, 2015
@reed
Copy link
Collaborator

reed commented Apr 18, 2015

Thanks

@Thibaut
Copy link
Collaborator Author

Thibaut commented Apr 18, 2015

@reed good catch on the name. data-turbolinks-eval=false was confusing.

On Apr 18, 2015, at 12:58, Nick Reed notifications@github.com wrote:

Thanks


Reply to this email directly or view it on GitHub.

@kevinhughes27
Copy link

I like it! thanks guys!

@Thibaut Thibaut deleted the scripts branch April 18, 2015 20:04
@gregblass
Copy link

Any idea how I could add this to code in application.js where there is no script tag? And any advice on how I'd go about using this with all the baked in bootstrap stuff that I'm using? (popovers, tooltips, modals, etc)

Edit: Stupid question. Just put your code in a script tag with data-turbolinks-eval=always on the bottom of your application.html.erb. It probably should be in application.js anyway. And take it out of a document onready. Then it will fire every time, even with back and forward.

@Thibaut
Copy link
Collaborator Author

Thibaut commented May 13, 2015

@gregblass bind a function to the page:load event. It'll get called every time the page changes (including on back/forward navigation).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Turbolinks doesn't run scripts on back
4 participants