Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

空链接内的span图标点击后不能正确生成日历 #36

Closed
encorehu opened this issue May 12, 2017 · 1 comment
Closed

空链接内的span图标点击后不能正确生成日历 #36

encorehu opened this issue May 12, 2017 · 1 comment

Comments

@encorehu
Copy link

encorehu commented May 12, 2017

html:
    

问题出在173行

jet.sortDate = function (time,format) {
    var timeObj = {}, newtime = [], mats = regymd.split("|"),
        subhh = jet.checkFormat(format).substring(0, 2) == "hh" ? true :false,
        numArr = jet.IsNum(time) ? (jet.reMacth(subhh ? time.replace(/(.{2})/g,"$1,") : time.substr(0,4).replace(/^(\d{4})/g,"$1,") + time.substr(4).replace(/(.{2})/g,"$1,"))) : jet.reMacth(time),
        matArr = jet.IsNum(time) ? (jet.reMacth(subhh ? format.replace(/(.{2})/g,"$1,") : format.substr(0,4).replace(/^(\w{4})/g,"$1,") + format.substr(4).replace(/(.{2})/g,"$1,"))) : jet.reMacth(format);
    $.each(numArr,function (i,val) {
        timeObj[matArr[i]] = val;
    });

这里的$.each有问题, 报错Uncaught TypeError: Cannot read property 'length' of null
问题是296行和297行

        var initVal = jet.isValHtml(objCell) ? objCell.val() : objCell.text();
        var inVals = jet.sortDate(initVal,jet.format);

initVal 是 4个空格   故 jet.sortDate 函数的 time是" ", 最后导致 numArr 是null(jet.reMacth(time)), 在后面的 $.each函数中调用jquery的each函数, 有个a.length>0 这种, 报错了.

解决办法, 就是:jet.sortDate(time,format), time值为空格或者多个空格, 应该设置一个默认值,比如当前时间.
这样就可以解决问题

                            if ($.trim(time)=="")
			{
			    var tmptime = new Date();
			    time = tmptime.format("yyyy-MM-dd hh:mm:ss");
			}
@encorehu
Copy link
Author

好像没有问题了, 请关闭这条issue吧

@singod singod closed this as completed May 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants