2013-05-15 54 views
0

jquery-easyui datebox(http://www.jeasyui.com/documentation/index.php)和Datejs api(http://www.datejs.com/)之间存在冲突。 jquery-easyui版本是1.3.3。JQuery easyui和Datejs日期冲突

当两者都包含在任何jsp页面中时,加强日历的当前日期总是为1970年1月。我找不到任何将datebox的值设置为当前日期的方法(不想使用字符串默认值,但是而应该自动设置当前日期)。我试着用下面的代码在文档

//get the calendar object 
var c = $('#dtbDueFrom').datebox('calendar'); 
// set the first day of week to monday 
c.calendar({ 
    current: new Date() 
}); 
} 

解释,但它引发异常TypeError: $.data(...) is undefined

$('#dtbDueFrom').datebox({current: new Date()}); 

这也行不通。

Datejs是一个非常有用的库,我不能从项目中删除它,因为我需要它提供的方法。消除它的工作绝对好,但有没有任何解决方法让两者合作。谢谢。

+1

注意[Datejs被放弃(解决方法HTTP:/ /stackoverflow.com/tags/datejs/info)。 –

回答

0

我还是没找到上述问题的精确解,但这里是我曾经按照我需要让我的datebox工作

Due Date <input id="dateDuetxt" class="easyui-datebox" style="width:100px"/> 

<script> 

$('#dateDuetxt').datebox({ 
    value: (new Date().toString('dd-MMM-yyyy')), /* Date.js toString function to convert date into format that is being used by datebox. */ 
    formatter : function(date){ 
     return date.toString('dd-MMM-yyyy'); 
    }, 
    parser : function(s){ 
     var t = Date.parse(s); 
     if (!isNaN(t)){ 
      return new Date(t); 
     } else { 
      return null; 
     } 
    } 
}); 

</script>