gpt4 book ai didi

jquery-ujs 已经加载rails

转载 作者:行者123 更新时间:2023-12-01 00:06:15 25 4
gpt4 key购买 nike

所以我正在尝试将谷歌地图集成到我的 Rails 应用程序中(请记住,这是我第一次这样做,而且我是 Rails 初学者,而且我不太了解 Ruby 代码)。

map 代码

<!-- 
You need to include this script on any page that has a Google Map.
When using Google Maps on your own site you MUST signup for your own API key at:
https://developers.google.com/maps/documentation/javascript/tutorial#api_key
After your sign up replace the key in the URL below or paste in the new script tag that Google provides.
-->
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDRKcd8KX82m0q47qSGB9Ryh79jqzjOpAk&sensor=false"></script>

<script type="text/javascript">
// When the window has finished loading create our google map below
google.maps.event.addDomListener(window, 'load', init);

function init() {
// Basic options for a simple Google Map
// For more options see: https://developers.google.com/maps/documentation/javascript/reference#MapOptions
var mapOptions = {
// How zoomed in you want the map to start at (always required)
zoom: 12,

// The latitude and longitude to center the map (always required)
center: new google.maps.LatLng(45.495040, -73.614371), // Montreal

// How you would like to style the map.
// This is where you would paste any style found on Snazzy Maps.
styles: [{"stylers":[{"hue":"#16a085"},{"saturation":0}]},{"featureType":"road","elementType":"geometry","stylers":[{"lightness":80},{"visibility":"simplified"}]},{"featureType":"road","elementType":"labels","stylers":[{"visibility":"off"}]}]
};
// Get the HTML DOM element that will contain your map
// We are using a div with id="map" seen below in the <body>
var mapElement = document.getElementById('map');

// Create the Google Map using out element and options defined above
var map = new google.maps.Map(mapElement, mapOptions);
}
</script> </head> <body>
<!-- The element that will contain our Google Map. This is used in both the Javascript and CSS above. -->
<div class="innerborder">
<div id="map"></div> </div>

出于某种原因,每当我单击包含 map 的页面时,它都会尝试加载 jquery-ujs 两次。这是我的 application.js 包含树

//= require jquery //= require jquery_ujs //= require turbolinks //=require_tree .

奇怪,继续得到这个:未捕获错误:jquery-ujs 已加载!

有什么想法给我吗?

谢谢!

最佳答案

我认为它来自涡轮链接。尝试禁用它们。我对它们有很多问题,最终把它们从一个项目中删除了。您可以使用此 gem 来解决此问题,但如果您仍想尝试,请首先尝试禁用它们: https://github.com/kossnocorp/jquery.turbolinks

关于jquery-ujs 已经加载rails,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20749622/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com