纸头折飞机
欢迎大家加入KitJs官方高级QQ群88093625,讨论前端技术,上海携程招聘H5,iOS,android,产品,设计,交互,测试,有意者发简历到xueduanyang1985@163.com
号外:kitjs官方讨论QQ群建立了,QQ群号88093625,欢迎大家加入,讨论前端相关话题 

 

 

地址:http://xueduany.github.com/KitJs/KitJs/index.html#datepicker_nmonth

 

界面如图

image

 

继承自之前发布的

http://www.cnblogs.com/xueduanyang/archive/2012/04/12/2444788.html

image

 

初始化方法为

//默认日历
                window.picker = new $kit.ui.DatePicker.NMonths();
                picker.init();
                $kit.el('#J_datePicker').appendChild(picker.picker);
                picker.show();
                picker.ev({
                    ev : 'change',
                    fn : function(e) {
                        alert(picker.getValue());
                    }
                })
                //输入框下拉
                $kit.ev({
                    el : '#J_input',
                    ev : 'focus',
                    fn : function(e) {
                        var d, ipt = e.target;
                        d = e.target[$kit.ui.DatePicker.defaultConfig.kitWidgetName];
                        if(d) {
                            d.show();
                        } else {
                            d = new $kit.ui.DatePicker.NMonths();
                            d.init();
                            d.adhere($kit.el('#J_input'));
                            d.show();
                        }
                    }
                });
                $kit.ev({
                    el : document,
                    ev : 'click',
                    fn : function(e) {
                        var input = $kit.el('#J_input');
                        d = input[$kit.ui.DatePicker.defaultConfig.kitWidgetName];
                        if(d && !$kit.contains(d.picker, e.target) && input != e.target) {
                            d.hide();
                        }
                    }
                });

 

与之前默认配置参数唯一的区别在于,多了一个配置显示多少个月的参数 nMonths,默认显示3个月,可以改成2个月

 

周末了,如果遇到啥问题,可以留言,下周继续更新,欢迎继续关注kitjshttp://xueduany.github.com/KitJs

posted on 2012-04-13 23:07  薛端阳  阅读(2126)  评论(10编辑  收藏  举报