移动到上一个/下一个完整日历jquery时将日期传递给控制器
我在我的查看页面中有完整的日历控件,我想在移动到上一周/下一周时将周开始日期传递给控制器。因此,我将其用于以下方面:移动到上一个/下一个完整日历jquery时将日期传递给控制器,jquery,asp.net-mvc,fullcalendar,Jquery,Asp.net Mvc,Fullcalendar,我在我的查看页面中有完整的日历控件,我想在移动到上一周/下一周时将周开始日期传递给控制器。因此,我将其用于以下方面: var calendar = $('#calendar').fullCalendar( { header: { left: 'prev', center: 'title', right: 'next' }, defaultView: 'basicWeek',
var calendar = $('#calendar').fullCalendar(
{
header: {
left: 'prev',
center: 'title',
right: 'next'
},
defaultView: 'basicWeek',
events: function (start, end, callback) {
$.get('events/get', function (result) {
callback(result);
});
startDate = $('#calendar').fullCalendar('getDate').startOf('week');
window.location.href = "/timesheet/index?selectDate=" + convertDate(startDate);
}
});
但现在它不断地重新加载页面,无法查看。。
谁能帮我做这件事。。
提前感谢..实际上
location.href
会一次又一次地呼叫自己。所以这是一个递归过程,为了摆脱这个过程,你需要做一些静态的(不是变量)但是像egs那样的web存储
实际上,
location.href
会一次又一次地调用自己。所以这是一个递归过程,为了摆脱这个过程,你需要做一些静态的(不是变量)但是像egs那样的web存储
....
startDate = $('#calendar').fullCalendar('getDate').startOf('week');
if(!localStorage.getItem('isConvertedDate')){ // if key is not set and first time load
localStorage.setItem('isConvertedDate',1); //set key, so that next time it will not refresh the page again
window.location.href = "/timesheet/index?selectDate=" + convertDate(startDate);
} else {
localStorage.removeItem('isConvertedDate');//remove if added
}
....
var calendar = $('#calendar').fullCalendar(
{
header: {
left: 'prev',
center: 'title',
right: 'next'
},
defaultView: 'basicWeek',
events: function (start, end, callback) {
$.get('events/get', function (result) {
callback(result);
});
}
});
$('.fc-prev-button').click(function () {
startDate = $('#calendar').fullCalendar('getDate').startOf('week');
window.location.href = "/TimesheetModels/EmpTimesheet?selectDate=" + convertDate(startDate);
});
$('.fc-next-button').click(function () {;
startDate = $('#calendar').fullCalendar('getDate').startOf('week');
window.location.href = "/TimesheetModels/EmpTimesheet?selectDate=" + convertDate(startDate);
});
var stdate = $('#startDateCalendar').val();
var testdate = new Date(stdate);
if (Date.parse(testdate)) {
$('#calendar').fullCalendar('gotoDate', testdate);
}
else{}