BlackBerry OS5 上的 Backbone - 有可能吗?

发布于 2025-01-05 12:13:04 字数 307 浏览 0 评论 0原文

我正在使用 Backbone、jQueryMobile 和 Phonegap 开发移动应用程序。该应用程序在 Android、iOS 和 BB >= 6 上运行良好,但在 BB5 上正如预期的那样,出现了无数问题。

我现在面临 Backbone 本身的问题。我正在调试它,看起来问题出在路由定义中。由于与其相关的原因,应用程序在启动时崩溃(仍在调查,但调试对于 BB5 来说很痛苦......)。

另外,我读到 BB5 无法很好地进行哈希侦听,而 Backbone 依靠哈希侦听来进行导航,所以我想知道是否有人能够在 OS5 上创建骨干应用程序,或者根本不可能?

I'm developing a mobile application using Backbone, jQueryMobile and Phonegap. The app works great on Android, iOS and BB >= 6, but on BB5 as expected there are countless issues coming up.

I'm now facing problems with Backbone itself. I'm debugging it and looks like the problem is in the routes definition. The application crashes on start time due to something related to it (still investigating, but debugging is painful for BB5...).

Also, I read that BB5 won't play nice with hash listening, which Backbone relies on to do the navigation, so I am wondering if somebody has been able to create a backbone app on OS5, or is it simply not possible?

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

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

发布评论

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

评论(2

已下线请稍等 2025-01-12 12:13:04

我正在更新这个问题,以防万一有人遇到同样的问题:

短篇故事:不可能在 OS5 上运行 Backbone。我调试到骨干网,一些带有正则表达式的指令导致崩溃。即使将来这些问题得到修复,我们也认为 js 支持不够好,最终放弃了 OS5 版本。

I'm updating this question just in case someone faces the same issue:

Short story: it's not possible to run Backbone on OS5. I debugged into backbone and some instructions with regular expressions were causing a crash. Even if these are fixed in the future, we determined that the js support was simply not good enough and finally discarded the OS5 version.

别想她 2025-01-12 12:13:04

在大多数情况下这可能不值得,但这是可行的。

经过相当多的工作后,我设法让一个应用程序运行 - OS 5.0 中的 javascript 支持确实不是很好,并且调试非常慢,正如 bfcapell 的答案中所建议的那样。

为了让主干工作,你需要注释掉使用 hashchange 事件来处理 url 更改的代码(假设正在使用路由器)。主干网中有一个后备方案,它使用 setinterval 来轮询更改。

    // Depending on whether we're using pushState or hashes, and whether
// 'onhashchange' is supported, determine how we check the URL state.
/*if (this._hasPushState)
{
    alert('pushstate');
    $(window).bind('popstate', this.checkUrl);
} else if (this._wantsHashChange && ('onhashchange' in window) && !oldIE)
{
    alert('hashchange');
    $(window).bind('hashchange', this.checkUrl);
} else if (this._wantsHashChange)
{*/
    this._checkUrlInterval = setInterval(this.checkUrl, this.interval);
//}

underscore中的foreach方法也需要修改为不使用原生的foreach方法。这是正确渲染集合所必需的。

var each = _.each = _.forEach = function (obj, iterator, context)
{
  if (obj == null) return;

  /*if (nativeForEach && obj.forEach === nativeForEach)
  {
      obj.forEach(iterator, context);
  }
  else*/
  if (obj.length === +obj.length)

上面的内容至少应该让主干大部分工作。 (我说主要是因为我有一个完全可以工作的应用程序,但我怀疑会及时发现更多 OS5 特定问题)。

It is probably not worth it in most cases but this is doable.

I managed to get an app running after quite a bit of work - the javascript support is really not great in OS 5.0 and debugging is very very slow as suggested in bfcapell's answer.

To get backbone to work you need to comment out the code that uses the hashchange event to handle url changes (this is assuming that the router is being used). THere is a fallback in backbone which uses setinterval to poll for changes.

    // Depending on whether we're using pushState or hashes, and whether
// 'onhashchange' is supported, determine how we check the URL state.
/*if (this._hasPushState)
{
    alert('pushstate');
    $(window).bind('popstate', this.checkUrl);
} else if (this._wantsHashChange && ('onhashchange' in window) && !oldIE)
{
    alert('hashchange');
    $(window).bind('hashchange', this.checkUrl);
} else if (this._wantsHashChange)
{*/
    this._checkUrlInterval = setInterval(this.checkUrl, this.interval);
//}

The foreach method in underscore also needs to be modified to not use the native foreach method. This is needed for collections to be rendered correctly.

var each = _.each = _.forEach = function (obj, iterator, context)
{
  if (obj == null) return;

  /*if (nativeForEach && obj.forEach === nativeForEach)
  {
      obj.forEach(iterator, context);
  }
  else*/
  if (obj.length === +obj.length)

The above should get at least backbone mostly working. (I say mostly because I have a completely working app but I suspect to find a couple more OS5 specific issues in time).

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