【发布时间】:2013-04-11 01:53:47
【问题描述】:
我真的想要一个将广告从 DFP 渲染到 ajax jquery UI 选项卡的解决方案。
我到处研究过,谷歌没有提供任何支持或文档。我有一个我一直在试验的示例 js 类。到目前为止,我一生都无法在标签加载时获得要呈现的广告。
我已经使用这个 gem https://github.com/digineo/google_dfp 加载了所有必要的依赖项。但我真的希望能够从 ajax 加载的内容中动态加载广告?
class @ScorecardViewController
constructor: (@element) ->
$(document).bind "tabsload", =>
@tabLoaded()
getGraphData: ->
tabLoaded: ->
@panel = $(CricTabsController.getLoadedPanel(@element))
@loadAdverts()
graphs = @panel.find(".match-graph").map (index, value) ->
$(value).attr("id")
@getGraphData() if graphs.length
loadAdverts: ->
tags = @panel.find("div.google-dfp")
googletag.cmd.push( ->
tags.each ->
$this = $(@)
googleAdSlot = googletag.defineSlot( $this.data('unit'), [$this.width(), $this.height()], $this.attr("id")).addService(googletag.pubads())
googletag.pubads().enableAsyncRendering()
googletag.enableServices()
googletag.display($this.attr("id"))
googletag.callback()
)
$ ->
$el = $('#sections-matches-scorecard')
if $el.length
new ScorecardViewController($el)
【问题讨论】:
标签: jquery ajax ruby-on-rails-3.2 google-dfp