骨干导航在Firefox中两次触发 [英] Backbone navigate triggers twice in Firefox

查看:103
本文介绍了骨干导航在Firefox中两次触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试使用骨干的导航属性。

Trying to use Backbone's navigate property.

 this.navigate("week/" + companyName + "/" + employeeNo + "/" + weekEnd, { trigger: true, replace: false });

在code以上被执行一次。

The code above is executed once.

它击中这样的:

routes: {
    "week/:companyName/:employeeNo/:weekEnd": "getWeek"
},

和则此函数被击中两次:

And then this function gets hit twice:

getWeek: function (companyName, employeeNo, weekEnd) {
    console.log('getWeek:', companyName, employeeNo, weekEnd);
 }

这是在Firefox在IE和Chrome登录两次,只有一次。

It is logged twice in Firefox, only once in IE and Chrome.

什么是这里的问题?我本来甚至没有触发设置为true,和Firefox忽略这一点,仍然引发了网址。

What's the issue here? I originally didn't even have trigger set to true, and Firefox ignored that and still triggered the URL.

推荐答案

我最近也有类似的问题,与Firefox做了Backbone.navigate经过两次服务器调用。在我的情况,那是因为我们没有带codeD的字符串。请问您的公司名称有这应该是EN codeD任何字符?

I had a similar issue recently with Firefox doing two server calls after a Backbone.navigate. In my case it was because we had not encoded the string. Does your company name have any characters which should be encoded?

您可以尝试:

this.navigate("week/" + escape(companyName) + "/" + employeeNo + "/" + weekEnd, { trigger: true, replace: false });

这篇关于骨干导航在Firefox中两次触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆