javascript - Rails 4 turbolinks page:load with JS -


i have following basic javascript ( coffeescript ) in app

window.onload = ->   menu = document.getelementbyid("menu")   wrapper = document.getelementbyid("wrapper")   togglemenu = false    menu.onclick = ->     if togglemenu false       wrapper.style.left = "278px"       togglemenu = true     else       wrapper.style.left = "0px"       togglemenu = false 

when click on turbolinks, stops working.

i found solution on so, don't know how implement in javascript:

$(document).on('page:change', function () {   // actions }); 

i did try document.onchange no success. pure javascript solution this?

document.addeventlistener('page:change', function(){   console.log('called') });  # page reloaded, no clicks yet => called # click turbolinks link => called 

Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -