Comments (8)
I Know inline js shouldn't even be in there but we should support inline js execution if we can.
from turbolinks-classic.
No js in your response body will operate at all.
This requires keeping everything out of the view including an init function call.
This is due to the use of DOMParser. it appears DOMParser will not evaluate javascript. document.write, however, will evaluate js to a point.
from turbolinks-classic.
Heck, I might jus consider this a feature ! :)
from turbolinks-classic.
My inner arsehole tends to agree with you! This should be given thought though - is Rails' stance to simply not recommend doing this, or to prevent it working at all?
from turbolinks-classic.
Right its also a potential issue that inline js using document references will have the wrong doc reference until after the content is replaced into the main document. A potential option is to scan for script tags after replace and evaluate them.
On Oct 1, 2012, at 12:21 PM, Daniel Beattie [email protected] wrote:
My inner arsehole tends to agree with you! This be given thought though - is Rails' stance to simply not recommend doing this, or to prevent it working at all?
—
Reply to this email directly or view it on GitHub.
from turbolinks-classic.
That sounds potentially brittle to me - I'd leave that up to caveat empor and making the developer aware of how this works. If you're using .js in this way and relying on document references like that, there should be some pain! I think we should just make sure .js can actually execute, and leave implementation details up to the .js author, rather than hacking a solution upstream on this library.
from turbolinks-classic.
I got it to work by modifying changePage to get all script elements. I have not made a pull request yet, as i know @dhh is doing a major refactor. But this may be useful... document also gets the proper reference because they are not evaluated until after the fact.
changePage = (title, body) ->
document.title = title
document.documentElement.replaceChild body, document.body
scripts = document.body.getElementsByTagName 'script'
eval(script.innerHTML) for script in scripts
currentState = historyState
triggerEvent 'page:change'
from turbolinks-classic.
Fixed
from turbolinks-classic.
Related Issues (20)
- Page does not always scroll to the top when DOM loads too fast
- SVG anchors not working with turbolinks
- Turbolinks.visit, partial replacement & relative urls (& IE11)
- Not correctly inferring protocol with SSL, unless force_ssl is set HOT 2
- Redirect and reload full page HOT 1
- JavaScript part of turbolinks on npm HOT 11
- Enable Turbolinks on a-tags after adding content over AJAX HOT 1
- File type blacklist instead of whitelist
- Scroll position of data-turbolinks-permanent elements lost on navigation. HOT 3
- Webpage without title, after turbolink has title of undefined HOT 1
- Problems with JS HOT 1
- Rails 5 deprecations
- Would you please tell me how to add your library or whether it's necessary to add this library?
- Sorry for duplicate
- Progress bar causing capybara tests to fail
- Documentation does not explain how to install current turbolinks-classic version HOT 1
- temporary inside permanent
- Clicking browser back button from an error page to a non-error page, retains the styles of the error page
- Turbolinks.enableProgressBar() returns undefined
- How to binding "page:load" cache-preview
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from turbolinks-classic.