我在表格部分的底部有这个,当我通过application.html.erb加载它时,之前有效,但后来我决定用appogle..b替换它。
_new.html.erb(字段恰当地为id' d)。直接上升不起作用,无法找出原因。
<script>
$(document).ready(function(){
var autocomplete = new google.maps.places.Autocomplete(document.getElementById("autocomplete"));
});
function initAutocomplete(){
}
</script>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCFm7OzAKuPbEa48b_aZ4S6JqMGVUCwwFs&libraries=places&callback=initAutocomplete"
async defer></script>
答案 0 :(得分:0)
尝试移动
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCFm7OzAKuPbEa48b_aZ4S6JqMGVUCwwFs&libraries=places&callback=initAutocomplete"
async defer></script>
到application.html.erb头标记
然后把
initAutocomplete = ->
$(document).ready ->
autocomplete = new (google.maps.places.Autocomplete)(document.getElementById('autocomplete'))
return
为您的首页加入coffeescript,或者如果需要,使用现有的内联部分内容进行测试。