easyui datebox控件点击今天按钮不触发onSelect事件的解决方法

来源:互联网 发布:阿里云oss附件存储 编辑:程序博客网 时间:2024/06/08 02:37

有时候用easyui detebox控件要取一个日期范围,可能会用到联动效果,这时候就会发现点击几天按钮不会触发onSelect事件,有个简单的方法可以解决这个问题:


增加一个onHidePanel事件,这个事件只负责处理“今天”,这个事件要在onSelect事件上面,这样你点击其他的日期的时候,还会触发onSelect,就不会出现错误啦


样式:

代码:

$('#halfyearE').datebox({onHidePanel : function() {var t = Date.parse(curtime);var curr_time = new Date(t);var strDate = curr_time.getFullYear() + "年";strDate += (curr_time.getMonth() + 1) + "月";var strDate1 = curr_time.getFullYear() + "年";if (curr_time.getMonth() == 11) {strDate1 += "01月";} else {strDate1 = (curr_time.getFullYear() - 1)+ "年";mv = (curr_time.getMonth() + 2);strDate1 += (mv < 10 ? '0' : '') + mv;strDate1 += "月";}$("#halfyearS").html(strDate1);$('#halfyearE').datebox('setValue', strDate);},onSelect : function(date) {var t = Date.parse(curtime);var nowdate = new Date(t);if (nowdate.getFullYear() < date.getFullYear()|| (nowdate.getFullYear() == date.getFullYear() && nowdate.getMonth() < date.getMonth())) {var curr_time = new Date(t);} else {var curr_time = new Date(date);}var strDate = curr_time.getFullYear() + "年";strDate += (curr_time.getMonth() + 1) + "月";var strDate1 = curr_time.getFullYear() + "年";if (curr_time.getMonth() == 11) {strDate1 += "01月";} else {strDate1 = (curr_time.getFullYear() - 1)+ "年";mv = (curr_time.getMonth() + 2);strDate1 += (mv < 10 ? '0' : '') + mv;strDate1 += "月";}//  strDate1 += curr_time.getDate();$("#halfyearS").html(strDate1);$('#halfyearE').datebox('setValue', strDate);}});
阅读全文
0 0
原创粉丝点击