Skip to content

Commit

Permalink
Execute external scripts in body
Browse files Browse the repository at this point in the history
  • Loading branch information
reed committed Oct 14, 2012
1 parent 6ff6f18 commit 58cba6f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/assets/javascripts/turbolinks.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,16 @@ changePage = (title, body) ->
triggerEvent 'page:change'

executeScriptTags = ->
eval(script.innerHTML) for script in document.body.getElementsByTagName 'script' when script.type in ['', 'text/javascript']
for script in document.body.getElementsByTagName 'script' when script.type in ['', 'text/javascript']
if script.src? and not script.getAttribute('data-turbolinks-evaluated')?
copy = document.createElement 'script'
copy.setAttribute attr.name, attr.value for attr in script.attributes
copy.setAttribute 'data-turbolinks-evaluated', ''
parent = script.parentNode
parent.removeChild script
parent.insertBefore copy, parent.childNodes[0]
else
eval(script.innerHTML)


reflectNewUrl = (url) ->
Expand Down

0 comments on commit 58cba6f

Please sign in to comment.