Google Gadget 画布视图在刷新之前无法与 gadgets.views 或 .params 通信?

发布于 2024-11-27 18:31:52 字数 1657 浏览 9 评论 0原文

我一直在开发一个可以在 iGoogle 中运行的小工具。事实上,它已经完成了,除了一个令人讨厌的错误,我们正在经历一场噩梦般的追捕。

请注意,代码片段位于 CoffeeScript 中;在我们将其托管给 Google 之前,它会被编译为 JS。我们还在代码中使用 Backbone.js,但这不会有太大区别,因为我们所有特定于 Backbone 的代码(initialize 方法等)都可以正常工作;我已经能够将代码的问题部分隔离在我们的 Backbone 之外

该小工具将首选选项列表以竖线分隔字符串 (55|34|101) 的形式保存到 Google 的 gadgets.prefs 对象中。

prefs = new gadgets.Prefs()
prefs.set('paramname','55|34|101')

这种保存效果很好,并且任何后续对 pref 的 get 的调用都可以正常工作。它们甚至可以通过 home 视图中的 prefs.get 调用来读取。当从 home 视图切换到 canvas 视图时,小工具无法获取这些首选项(从 canvas 视图)。

prefs = new gadgets.Prefs()
prefs.get('paramname')

只有在整个 canvas 视图页面上执行刷新后,小工具才会检索这些首选选项。

现在明白了:我们已尝试将这些首选项作为参数在 < code>home 和 canvas 视图。

(home view)
params = 
    'paramname': '55|34|101'
gadgets.views.requestNavigateTo('canvas', params)

(canvas view)
@params = gadgets.views.getParams()

这成功地将我们发送到 canvas,但在将 home 切换到 canvas 并尝试与 gadgets.views.getParams()< /code>,返回一个空对象。仅当刷新完成后,小工具才会处理相同的调用、查找参数并使用它们。

在这两个视图中,运行的最后一段代码是......

gadgets.util.registerOnLoadHandler init

它调用我们的 init() 函数......

init = ->
    @params = gadgets.views.getParams()

它返回一个空对象,除非我们刷新页面。

知道为什么会发生这种情况吗?我没有正确“启动”gadgets.* 东西吗?这几乎就像我正在与一个未“绑定”到我的特定小工具的 gadgets.* 对象交谈,直到我刷新页面(然后强制它绑定到画布视图)。请帮忙!

I've been working on a gadget that will run in iGoogle. In fact, it's finished, aside from a nasty bug that we're having a nightmare of a time hunting down.

Note that the code snippets are in CoffeeScript; it's compiled to JS before we host it up for Google. We're also using Backbone.js for our code, but that shouldn't make much difference as all of our Backbone-specific code (initialize methods and so forth) work just fine; I've been able to isolate the problem parts of the code outside of our Backbone stuff.

The gadget saves a list of preferred options to Google's gadgets.prefs object, as a pipe-delimited string (55|34|101).

prefs = new gadgets.Prefs()
prefs.set('paramname','55|34|101')

This save happens just fine, and any subsequent call to get that pref works just fine. They're even readable by a prefs.get call in the home view. It's when switching from the home view to the canvas view that the gadget isn't able to get those preferences (from the canvas view).

prefs = new gadgets.Prefs()
prefs.get('paramname')

Only once you do a Refresh on the whole canvas view page will the gadget retrieve those preferred options.

Now get this: we've tried passing these preferences as params between the home and the canvas view as well.

(home view)
params = 
    'paramname': '55|34|101'
gadgets.views.requestNavigateTo('canvas', params)

(canvas view)
@params = gadgets.views.getParams()

This successfully sends us to canvas, but after switching home to canvas and trying to talk to gadgets.views.getParams(), an empty object is returned. Only once a Refresh is done does the gadget process that same call, find the params, and use them.

In both views, the last piece of code run is…

gadgets.util.registerOnLoadHandler init

Which calls our init() function…

init = ->
    @params = gadgets.views.getParams()

…which returns an empty object, unless we refresh the page.

Any idea why this is happening? Am I not "kickstarting" the gadgets.* stuff properly? It's almost like I'm talking to a gadgets.* object that's not "bound" to my particular gadget, until I refresh the page (which then forces it to bind to the canvas view). Please help!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夏至、离别 2024-12-04 18:31:52

看起来,这是 Google 用于在 home/canvas 视图之间切换的新 AJAX 加载技术的问题。我们联系了 Google 的 iGoogle/OpenSocial 团队,得到了这样的答复。他们能够用自己的小工具重现该错误。在他们修复此问题之前,请使用 http://google.com/ig?aig=0 访问 iGoogle应该解决这个问题。

As it seems, it's an issue with Google's new AJAX loading technology used in switching between home/canvas views. We contacted Google's iGoogle/OpenSocial team and that's the response we got. They were able to reproduce the bug with a gadget of their own. Until they fix it, accessing iGoogle with http://google.com/ig?aig=0 should band-aid the issue.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文