移动到 Prev/Next FullCalendar jquery 时将日期传递给控制器
Pass date to controller when move to Prev/Next FullCalendar jquery
我在我的视图页面中有完整的日历控制,我想在移动到 prev/next 周时将周开始日期传递给控制器。所以,我将它与以下内容一起使用:
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
会一次又一次的调用自己。所以这是一个递归过程,为了摆脱这个过程,你需要做一些静态的(不是变量)但是像 localStorage for egs,
这样的网络存储
....
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{}
我在我的视图页面中有完整的日历控制,我想在移动到 prev/next 周时将周开始日期传递给控制器。所以,我将它与以下内容一起使用:
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
会一次又一次的调用自己。所以这是一个递归过程,为了摆脱这个过程,你需要做一些静态的(不是变量)但是像 localStorage for egs,
....
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{}