There is a conflict between jquery-easyui datebox (http://www.jeasyui.com/documentation/index.php) and Datejs api (http://www.datejs.com/). jquery-easyui version is 1.3.3 .
When both are included in any jsp page, poped up calendar's current date is always Jan, 1970. I could not find any methods that would set datebox's value to the current date (do not want to use a string default value but rather the current date should be automatically be set). I tried using following code as explained in documentation
//get the calendar object
var c = $('#dtbDueFrom').datebox('calendar');
// set the first day of week to monday
c.calendar({
current: new Date()
});
}
but it throws the exception TypeError: $.data(...) is undefined
.
$('#dtbDueFrom').datebox({current: new Date()});
This does not work either.
Datejs is a really helpful library and I cannot remove it from project as I need the methods it provides. Eliminating it works absolutely fine but is there any workaround to get both work along. Thanks.
I still could not find exact solution to the problem above but here is the workaround that I used to make my datebox work according to my need
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>