问题
= gmaps(markers: { data: @json, options: @marker_options }, map_options: @map_options )
- content_for :map_scripts do
:javascript
Gmaps.map.callback = function() {
alert('asdf') // <-- I never see this alert
}
Using the gmaps4rails gem (v1.5.2), I placed the code above in my view. My map appears fine with my markers. But with my javascript, shouldn't I get an alert (I'm not)? I'm not sure if I understand the callback completely.
FYI, the javascript appears fine in my source.
回答1:
It should be content_for :scripts
as mentioned in the doc
Plus depending on your browser, you'd better have: alert('asdf');
instead of alert('asdf')
来源:https://stackoverflow.com/questions/14144350/gmaps4rails-callback-not-firing