当用户点击fullcalendar的黑色部分时,我想知道如何允许用户填写表单而不是弹出的促销框
这基本上是我到目前为止所做的。正如你所看到的,我把数据发送到一个有效的PHP页面,但是我对提示框不满意,而是希望它能够很好地添加注释。< / p>
select: function(start, end, allDay) {
var title = prompt('Event Title:');
if (title) {
calendar.fullCalendar('renderEvent',
{
title: title,
start: start,
end: end,
allDay: allDay,
},
true // make the event "stick"
);
year = new Date(start).getFullYear();
month = new Date(start).getMonth()+1;
month = ((month < 10) ? '0' : '') + month;
day = ((new Date(start).getDate() < 10) ? '0' : '') + new Date(start).getDate();
hours = ((new Date(start).getHours() < 10) ? '0' : '') + new Date(start).getHours();
min = ((new Date(start).getMinutes() < 10) ? '0' : '') + new Date(start).getMinutes();
sec = ((new Date(start).getSeconds() < 10) ? '0' : '') + new Date(start).getSeconds();
start = year + '-' + month + '-' + day +' '+hours+':'+min+':'+sec;
year = new Date(end).getFullYear();
month = new Date(end).getMonth()+1;
month = ((month < 10) ? '0' : '') + month;
day = ((new Date(end).getDate() < 10) ? '0' : '') + new Date(end).getDate();
hours = ((new Date(end).getHours() < 10) ? '0' : '') + new Date(end).getHours();
min = ((new Date(end).getMinutes() < 10) ? '0' : '') + new Date(end).getMinutes();
sec = ((new Date(end).getSeconds() < 10) ? '0' : '') + new Date(end).getSeconds();
end = year + '-' + month + '-' + day +' '+hours+':'+min+':'+sec;
//alert(start+' - '+end);
$.get("system/classes/core.php?task=calendar&q=addnew&userid="+userid+"&title="+title+"&start="+start+"&end="+end+"&allDay="+allDay, function(data) {
alert(title + ' was created for '+ start +' '+ end);
});
}
calendar.fullCalendar('unselect');
},
答案 0 :(得分:1)
您需要先创建一个包含标题的表单以及您要提交的其他所有内容。然后将它包装在一个隐藏的div中。像这样......(简单的例子)
<div class="popup" style="display:none; position:fixed; top:25%; left:25%; background-color:white;">
<input class"title" type="text" size="26" />
<a href="#" onclick="return false" class="submitFrom">submit</a> 
<a href="#" onclick="return false" class="exit">cancel</a>
</div>
每次选择时,它都会显示隐藏div的.show()。填写表格并在提交.click()表格提交后,它会发送信息并再次隐藏div。
select: function(start, end, allDay){
$(".popup").show();
var start = Date.parse(start) / 1000;
var end = Date.parse(end) / 1000;
var allDay = allDay;
var wipit = // create a session id such as a random number that can be cleared later to prevent double submissio
$(".submitForm").click(function(){
var title = $(".title").val();
if(title){
$.post("/*page name*/", {title: title, start:start, end:end, allDay:allDay}, function(){
$(".title").val("")
title = "";
wipit = "";
start = '';
end = '';
allDay = '';
calendar.fullCalendar('unselect');
calendar.fullCalendar('refetchEvents');
});
} else {
// clear all information, unselect events, and alert that a title needs to be entered
}
$(".popup").hide();
});
$(".exit").click(function(){
// clear all info, unselect events and...
$(".popup").hide();
});
}
同样,这非常简单,并且必须根据您的规格进行修改以及根据您的喜好进行修改,但它应该有效。如果有帮助,请告诉我