jQuery fullCalendar + Fancybox 弹出窗口可编辑事件
我正在使用此代码在 fullCalendar 上生成事件,
<script type="text/javascript">
$(document).ready(function() {
$('#calendar').fullCalendar({
// put your options and callbacks here
header: {
right: 'today month,agendaWeek,agendaDay prev,next'
},
events: [
<?php foreach($cal_data as $row): ?>
{
title : '<?php echo $row->plant_name . ' ' . $row->value_2; ?>',
start : '<?php echo $row->date . ' ' . $row->time; ?>',
allDay: false,
url : '<?php echo base_url() . 'events/events_edit/' . $row->record_id; ?>'
},
<?php endforeach; ?>
],
});
});
</script>
这对于数据显示效果很好。当我单击该事件时,会加载一个新页面以供编辑。
现在我需要在 jQuery Fancybox 弹出窗口内进行编辑。
基于 fullCalendar API,我将
eventClick: function(event) {
if (event.url) {
window.open(event.url);
return false;
}
}
在整个项目中使用此 Fancybox 代码来成功编辑弹出窗口内的其他内容:
$.fancybox({
'transitionIn': 'none',
'transitionOut': 'none',
'type': 'ajax',
'href': link,
'onClosed': function() {
parent.location.reload(true);
}
});
$.bind("submit", function() {
$.fancybox.showActivity();
$.ajax({
type: "POST",
cache: false,
data: $(this).serializeArray(),
success: function(data) {
$.fancybox(data);
}
});
return false;
});
但我无法将其集成到 fullCalendar 脚本中。
例如,这不起作用:
eventClick: function(event) {
if (event.url) {
$.fancybox({
'transitionIn': 'none',
'transitionOut': 'none',
'type': 'ajax',
'href': link,
'onClosed': function() {
parent.location.reload(true);
}
});
$.bind("submit", function() {
$.fancybox.showActivity();
$.ajax({
type: "POST",
cache: false,
data: $(this).serializeArray(),
success: function(data) {
$.fancybox(data);
}
});
return false;
});
return false;
}
}
有什么建议如何完成此操作吗?
非常感谢您的帮助!
I am generating events on fullCalendar with this code
<script type="text/javascript">
$(document).ready(function() {
$('#calendar').fullCalendar({
// put your options and callbacks here
header: {
right: 'today month,agendaWeek,agendaDay prev,next'
},
events: [
<?php foreach($cal_data as $row): ?>
{
title : '<?php echo $row->plant_name . ' ' . $row->value_2; ?>',
start : '<?php echo $row->date . ' ' . $row->time; ?>',
allDay: false,
url : '<?php echo base_url() . 'events/events_edit/' . $row->record_id; ?>'
},
<?php endforeach; ?>
],
});
});
</script>
This works fine for data display. When I click on the event a new page is loaded for editing.
Now I need to edit inside a jQuery Fancybox popup.
Based on the fullCalendar API, I would use
eventClick: function(event) {
if (event.url) {
window.open(event.url);
return false;
}
}
I am using this Fancybox code throughout the project to successfully edit other things inside popups:
$.fancybox({
'transitionIn': 'none',
'transitionOut': 'none',
'type': 'ajax',
'href': link,
'onClosed': function() {
parent.location.reload(true);
}
});
$.bind("submit", function() {
$.fancybox.showActivity();
$.ajax({
type: "POST",
cache: false,
data: $(this).serializeArray(),
success: function(data) {
$.fancybox(data);
}
});
return false;
});
But I haven't been able to integrate it into the fullCalendar script.
For example this doesn't work:
eventClick: function(event) {
if (event.url) {
$.fancybox({
'transitionIn': 'none',
'transitionOut': 'none',
'type': 'ajax',
'href': link,
'onClosed': function() {
parent.location.reload(true);
}
});
$.bind("submit", function() {
$.fancybox.showActivity();
$.ajax({
type: "POST",
cache: false,
data: $(this).serializeArray(),
success: function(data) {
$.fancybox(data);
}
});
return false;
});
return false;
}
}
Any suggestions how to get this done?
Thanks a lot for helping!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
理论上你的代码看起来可以工作。但是你告诉你的 fancybox 打开一个未定义的变量
link
,而不是使用event.url
。另外,不要使用这里有点重的parent.location.reload(this)
(您可以动态添加事件,因此无需重新加载整个页面)< /em>,您可以取消onClosed()
事件:然后在
.ajax()
的success
方法中,您可以从您的events/events_edit/
页面返回一个 json 字符串(包含新的事件数据,与页面加载时添加的样式相同),然后在 success 方法中使用 fullcalendars addEventSource 并传递 json 对象以添加到 callendar 中:如果没有,很难测试其中任何一个一切都已设置完毕,但它可能会给您一些想法,引导您走向正确的方向。
In theory your code looks like it would work. But you are telling your fancybox to open an undefined variable
link
, instead useevent.url
. Also, instead of usingparent.location.reload(this)
which is a bit heavy here (you can add events on the fly, so there is no need to reload the entire page), you could do away with theonClosed()
event:Then in your
.ajax()
'ssuccess
method, you could return a json string from yourevents/events_edit/
page (containing the new event data, same style as you add when the page loads), then in the success method use fullcalendars addEventSource and pass the json object over to be added on to the callendar:Its difficult to test any of this without having it all setup, but it may give you some ideas to point you towards the right direction.
获得成功后,您只需在日历中呈现该事件即可。
After Getting Success you just have to just render that event in the calendar.