datebox setValue与setText是一样的,都是设置的是字面值,这样在使用的时候很不方便,通过扩展setDate,getDate来直接操作date,将更容易
$.extend($.fn.datebox.methods,{
//value 存储long,Text存字面值,date放置在calendar内
setDate:function(elements,date){
if(typeof date!="object"){
return;
}
var me=this;
elements.each(function(){
$.fn.datebox.methods._setDate(this,date);
});
},
_setDate:function(element,date){
var datebox = $.data(element, "datebox");
var opts = datebox.options;
var value=date.getTime();
var text=opts.formatter(date);
$(element).combo("setValue", value).combo("setText", text);
datebox.calendar.calendar("moveTo", date);
},
getDate:function(elements){
//设置值请使用setDate
return new Date(elements.datebox('getTime'));
},
getTime:function(elements){
//设置值请使用setDate
return new Number(elements.datebox('getValue'));
}
});