日历插件版本:CURRENT RELEASE 1.2.1
我遵循了grails插件文档中提到的步骤,在所有类型的浏览器中都收到以下错误
Chrome 14.0835:未捕获RangeError:超出了最大Callstack大小。
Firefox 6.02:太多的递归calendar.js行1851
IE 9:堆栈空间不足calendar.js行1850
最佳答案
令人讨厌的jscalendar代码是这样的:
Date.prototype.__msh_oldSetFullYear = Date.prototype.setFullYear;
Date.prototype.setFullYear = function(y) {
var d = new Date(this);
d.__msh_oldSetFullYear(y);
if (d.getMonth() != this.getMonth())
this.setDate(28);
this.__msh_oldSetFullYear(y);
};
其中重新定义了
Date.setFullYear()
。看看此"old jscalendar" page上的注释#124和#125。评论#124(克里斯·利弗利(Chris Lively))
建议更新calendar.js(在底部,第1850行附近)。
For those getting the recursion error. You just need to comment a few lines. See below.
//Date.prototype.msh_oldSetFullYear = Date.prototype.setFullYear; Date.prototype.setFullYear = function(y) { var d = new Date(this); //d.msh_oldSetFullYear(y); if (d.getMonth() != this.getMonth()) this.setDate(28); //this._msholdSetFullYear(y); };
评论#125(larisa的回复)
The problem with recursion occurs due to multiple includes of calendar JavaScript on a page. As a result Date patch redefines setFullYear function twice and causes infinite loop when it gets executed. We fixed it by making sure that function is redefined only once:
if(Date.prototype.msh_oldSetFullYear == null) { Date.prototype.msh_oldSetFullYear = Date.prototype.setFullYear; }
这两个建议都建议对calendar.js进行更新,由于它是随插件一起提供的,因此并不理想。
两个建议:
<calendar:resources/>
?如果是这样,请删除其中之一。 关于grails - Grails Calendar插件抛出堆栈/递归错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7551662/