我正在尝试为我的应用程序制作日历,当我第一次点击日期时,回调方法被调用1次(如预期的那样),但是当我点击日期(月中的任何日期)第二次然后回调被称为2次(应该被称为1次),依此类推......
点击日历中的某一天时:
onDayClick = function(date, jsEvent, view){
//alert('Date: ' + date.format() + '\n' + 'Current View: ' + view.name + '\n' + 'Make a form here.');
//console.log('Called onDayClick ' + global_counter++);
createForm(function(form){
console.log('createForm Callback');
event = {
start : date
}
onModalRendered(event);
});
//$(this).css('background-color', 'red');
}
createForm = function(cb){
console.log('createForm');
var form = $('#myModal');
form.modal('show');
form.on('shown.bs.modal', function(){
cb(form);
});
return false;
}
控制台日志输出如下:
Called onDayClick 0 //day clicked in calendar (say, 5 Sep)
createForm
createForm Callback
onModalRendered
Called onDayClick 1 //day clicked in calendar (say, 6 Sep) here callback should be called 1 time
createForm
createForm Callback
onModalRendered
createForm Callback
onModalRendered
我觉得我在制作回调函数时犯了一些错误。请指出我的错误。