我尝试添加完整日历。我第一次点击按钮,它增加了成功。在我使用jquery empty()
方法清除ScheduleCalender div之后。然后我重新运行完整的日历代码。但是没有出现完整的压延机。至少没有内容出现在div内。在这里我的代码。我的div选择器工作正常。我测试了那个。
$('#addNewTimeScheduleEntry').click(function () {
$('#scheduleCalendar').empty();
var scheduleYear = $('.scheduleYear').val();
var scheduleMonth = $('.scheduleMonth').val();
$('#scheduleCalendar').fullCalendar({
defaultDate: scheduleYear + '-' + scheduleMonth + '-01',
header: {
left: '',
center: '',
right: 'title'
},
eventRender: function (event, element) {
element.qtip({
content: event.description,
style: {
classes: 'qtip-dark qtip-shadow'
},
position: {
my: 'top left', // Position my top left...
at: 'bottom right', // at the bottom right of...
target: $(element) // my target
}
});
},
height: $('.panel-body').height()-50
});
});
这是我的HTML
<div class="panel-body fixed-content">
<div class="year-month-control">
<select class="selectpicker scheduleYear">
</select>
<select class="selectpicker scheduleMonth">
</select>
<button type="button" id="addNewTimeScheduleEntry" class="btn btn-default" id="addnewScheduleEntry"><i class="fa fa-plus"></i> Add Entry</button>
<button type="button" id="addNewTimeScheduleEntry" class="btn btn-default" id="saveScheduleEntry" ><i class="fa fa-upload"></i> Save Entry</button>
</div>
<br/>
<div id='scheduleCalendar'></div>
</div>
答案 0 :(得分:1)
即使在清空div之后它也能正常运行。唯一的区别是我把它放在文件准备活动中,但我不认为这应该有任何区别。这里有2个jsfiddles; http://jsfiddle.net/2qs8tyg1/2/
$(document).ready(function() {
$('#addNewTimeScheduleEntry').click(function () {
$('#scheduleCalendar').empty();
$('#scheduleCalendar').fullCalendar({});
var scheduleYear = date.getFullYear();
var scheduleMonth = date.getMonth();
$('#scheduleCalendar').fullCalendar({
defaultDate: scheduleYear + '-' + scheduleMonth + '-01',
header: {
left: '',
center: '',
right: 'title'
},
eventRender: function (event, element) {
element.qtip({
content: event.description,
style: {
classes: 'qtip-dark qtip-shadow'
},
position: {
my: 'top left', // Position my top left...
at: 'bottom right', // at the bottom right of...
target: $(element) // my target
}
});
},
height: $('.panel-body').height()-50
});
});
});
http://jsfiddle.net/justinobney/uaNgR/
jQuery(document).ready(function() {
var date = new Date();
var d = date.getDate();
var m = date.getMonth();
var y = date.getFullYear();
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
viewDisplay: function(view) {
window.location.hash = "month=" + (view.start.getMonth() + 1) + "&year=" +view.start.getFullYear();
},
editable: true,
events: [
{
title: 'All Day Event',
start: new Date(y, m, 1)
},
{
title: 'Long Event',
start: new Date(y, m, d-5),
end: new Date(y, m, d-2)
},
{
id: 999,
title: 'Repeating Event',
start: new Date(y, m, d-3, 16, 0),
allDay: false
},
{
id: 999,
title: 'Repeating Event',
start: new Date(y, m, d+4, 16, 0),
allDay: false
},
{
title: 'Meeting',
start: new Date(y, m, d, 10, 30),
allDay: false
},
{
title: 'Lunch',
start: new Date(y, m, d, 12, 0),
end: new Date(y, m, d, 14, 0),
allDay: false
},
{
title: 'Birthday Party',
start: new Date(y, m, d+1, 19, 0),
end: new Date(y, m, d+1, 22, 30),
allDay: false
},
{
title: 'Click for Google',
start: new Date(y, m, 28),
end: new Date(y, m, 29),
url: 'http://google.com/'
}
]
});
function setupRouting() {
$.jsRouter.mapRoute('Month Change', 'month={month}&year={year}', MonthChanged);
}
function MonthChanged(args) {
var vMonth = args.month;
var vYear = args.year;
console.log('event trapped:', args);
}
$.getScript('http://www.tasktrackr.com/js/routing.js',setupRouting);
//jQuery.deparam.fragment()
//$.getScript('https://raw.github.com/cowboy/jquery-bbq/master/jquery.ba-bbq.min.js')
});