assign to selectedDate even if date is not supplied.

update initDatePicker to accept date. This date will be the setDate argument for bootstrap datepicker.
error is here, its not assigning the date correctly for the picker.
#5
This commit is contained in:
Chris.Watts90@outlook.com 2017-02-10 12:43:23 +00:00
parent 19b718a946
commit 832426608c
2 changed files with 9 additions and 4 deletions

View File

@ -130,7 +130,7 @@ namespace SQLiteRepository
var now = DateTime.UtcNow;
var calendarWeek = GetIso8601CalendarWeek(now);
ret.CalendarWeek = calendarWeek;
ret.SelectedDate = now;
ret.TimeLogs = GetTimeLogList(userId, calendarWeek, now.Year);
return ret;

View File

@ -141,7 +141,7 @@
self.dismissAlert = function(data, event) {
self.errorData(null);
};
self.initDatePicker = function () {
self.initDatePicker = function (selectedDate) {
$("#weeklyDatePicker").datepicker({
weekStart: 1,
maxViewMode: 2,
@ -151,7 +151,12 @@
todayHighlight: true,
calendarWeeks: true
});
$("#weeklyDatePicker").datepicker("setDate", new Date().toDateString("yyyy-mm-dd"));
if (!selectedDate) {
selectedDate = new Date().toDateString("yyyy-mm-dd");
} else {
selectedDate = new Date(selectedDate).toDateString("yyyy-mm-dd");
}
$("#weeklyDatePicker").datepicker("setDate", selectedDate);
console.log("finished init");
};
self.assignHandler = function () {
@ -229,7 +234,7 @@
false);
$.getJSON(url, function (res) {
self.userTimeLogData(res);
self.initDatePicker();
self.initDatePicker(res.SelectedDate);
self.assignHandler();
}).fail(function (resp, status, error) {
console.log("error - getuserdetails");