grails - Grails Calendar插件抛出堆栈/递归错误

标签 grails plugins calendar jscalendar

日历插件版本: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进行更新,由于它是随插件一起提供的,因此并不理想。

两个建议:
  • 确保您没有两次导入日历资源。您的主布局和 View GSP中是否有<calendar:resources/>?如果是这样,请删除其中之一。
  • 如果那不起作用,请使用其他插件。日历插件看起来好像已经有一段时间没有更新了(它使用的是jscalendar的旧版本)。如果您有雄心壮志,可以自己更新插件!
  • 关于grails - Grails Calendar插件抛出堆栈/递归错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7551662/

    相关文章:

    grails - Grails Map域类的列名问题

    spring - 如何在运行时检查资源文件是否存在[grails]?

    grails - 双向一对一

    javascript - 在 jQuery 周历插件中将非工作时间变灰

    javascript - 使用事件发生时间的约束来安排应用程序

    iOS 订阅 webcal 日历

    Java Calendar对象,分别设置日期和时间

    spring - 另一个 Controller 中的Grails Spring安全性登录表单

    javascript - 如何使用 jQuery 将 div 置于页面中间并在调整窗口大小时保持其居中?

    cocoa - .so 运行时可链接库作为插件; cocoa 能力?