refreshScroll:function(){ 下面开头总价改为入下代码,<input value="2015-02-05" /> var initVal = that.acceptId.value; var initValArr = initVal != "" ? that.acceptId.value.split(that.format) : []; var inputYear,inputMonth,inputDay; if(initValArr.length>0){ inputYear = that.dateForTen2(initValArr[0]); inputMonth = that.dateForTen2(initValArr[1]); inputDay = that.dateForTen2(initValArr[2]); } //增加函数 去除数字前面的0 dateForTen2: function(n){ return n.replace(/\b(0+)/gi,""); },
最近在使用这个插件发现编辑的时候不能回调时间显示 ,没有默认时间值。于是想着修改一下插件,果然实现了。
1、回显时直接value给赋值。时间格式和你定义的format一致 2015-02-03
2、修改原Mdate.js ,用JS格式化工具格式化一下,然后修改如下
refreshScroll: function() 里面修改为
refreshScroll: function() { var that = this; var initVal = that.acceptId.value; var initValArr = initVal != "" ? that.acceptId.value.split(that.format) : []; var inputYear,inputMonth,inputDay; if(initValArr.length>0){ inputYear = that.dateForTen2(initValArr[0]); inputMonth = that.dateForTen2(initValArr[1]); inputDay = that.dateForTen2(initValArr[2]); } inputYear = inputYear || that.beginYear; inputMonth = inputMonth || that.beginMonth; inputDay = inputDay || that.beginDay; initM = that.beginMonth; initD = that.beginDay; if (inputYear != that.beginYear && initM != 1) { initM = 1 } if (inputMonth != that.beginMonth && initD != 1) { initD = 1 } inputYear -= that.beginYear; inputMonth -= initM; inputDay -= initD; yearScroll.refresh(); yearScroll.scrollTo(0, inputYear * 40, 300, true); monthScroll.scrollTo(0, inputMonth * 40, 300, true); dayScroll.scrollTo(0, inputDay * 40, 300, true) }, //去掉里面的0 dateForTen2: function(n){ return n.replace(/\b(0+)/gi,""); },