GMaps4Rails and Turbolinks not loading without full page refresh

前端 未结 6 1688
悲哀的现实
悲哀的现实 2020-12-28 09:32

I\'m using gmaps4rails to load a map on a \"clients\" show page. I\'ve integrated turbolinks to make the app speadier all together, but now I\'m hitting an issue where I hav

6条回答
  •  一生所求
    2020-12-28 09:54

    I had trouble filling the map canvas on revisits to pages already managed by turbolinks, especially when using the back button. I fixed the issue by adding a listener, for the turbolinks event page:load, to map initialization.

    map.js.coffee

    google.maps.event.addDomListener(window, 'load', @_setup)
    google.maps.event.addDomListener(window, 'page:load', @_setup)
    

    application.js.coffee

    //= require jquery
    //= require jquery.turbolinks
    

提交回复
热议问题