gmaps4rails callback not firing

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 05:03:24

问题


    = 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!