data-turbolinks-permanent 阻止 js 运行 & 摆脱 google 地图标记
data-turbolinks-permanent prevents js from running & gets rid of google map markers
我已将 data-turbolinks-permanent 添加到 div:
<div id="map" data-turbolinks-permanent></div>
但是在更改页面并返回时,我的地图标记消失了。
以下是我包含js的方式:
<%= javascript_include_tag "https://maps.googleapis.com/maps/api/js?v=3&key=key&libraries=places&callback=loadMap", "async" => true, "defer" => true -%>
<%= javascript_include_tag 'map.js' -%>
当我包含 data-turbolinks-track => 重新加载到 google 地图时,js 包含在页面更改时显示的标记,但它当然会重新加载;我希望元素和 js 在页面加载时保持不变。
注意:gmaps js include 中的 key 参数是为了隐藏我的 API key
我转而决定使用 locationStorage 和 sessionStorage HTML5 API;我需要的是在返回时记住应用程序的状态:
从#map div 中删除了 data-turbolinks-permanent,然后在 google 地图上使用了 'data-turbolinks-track => reload' api js 包含,然后使用了 localStorage & sessionStorage API's.
我已将 data-turbolinks-permanent 添加到 div:
<div id="map" data-turbolinks-permanent></div>
但是在更改页面并返回时,我的地图标记消失了。
以下是我包含js的方式:
<%= javascript_include_tag "https://maps.googleapis.com/maps/api/js?v=3&key=key&libraries=places&callback=loadMap", "async" => true, "defer" => true -%>
<%= javascript_include_tag 'map.js' -%>
当我包含 data-turbolinks-track => 重新加载到 google 地图时,js 包含在页面更改时显示的标记,但它当然会重新加载;我希望元素和 js 在页面加载时保持不变。
注意:gmaps js include 中的 key 参数是为了隐藏我的 API key
我转而决定使用 locationStorage 和 sessionStorage HTML5 API;我需要的是在返回时记住应用程序的状态:
从#map div 中删除了 data-turbolinks-permanent,然后在 google 地图上使用了 'data-turbolinks-track => reload' api js 包含,然后使用了 localStorage & sessionStorage API's.