2013-05-15 49 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>