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
Post a Comment