这可能听起来很简单,但是如何传递SELECT函数的变量来填充div表单?
我已成功设置FC并使用SELECT函数触发表单“new_event”的外观。
select: function( startDate, endDate, allDay, jsEvent, view) {
$("#new_event").show();
},
我现在需要使用startDate等填充表单。一旦完成,表单将通过PHP对mySQl后端进行必要的更改。
答案 0 :(得分:0)
这是我的选择,它会生成添加事件表单
select: function(start, end, allDay) {
var calendars = getAjaxData('calendar/calendarsJson');
var txt = '<h3>Dodaj nov dogodek:</h3>\n\
<div class="clear"></div>\n\
<p><label>'+CI.lang.language.what+':</label><input type="text" name="title" value="" /></p>\n\
<p><label>'+CI.lang.language.where+':</label><input type="text" name="location" value="" /></p>\n\
<p><label>'+CI.lang.language.description+':</label></p>\n\
<p><textarea name="description"></textarea></p>';
txt += '<p><label>'+CI.lang.language.calendar+':</label>\n\
<select name="id_calendar">';
for(i=0;i<calendars.length;i++) {
txt += '<option value="'+calendars[i].id_calendar+'">'+calendars[i].title+'</option>';
}
txt += '</select></p>';
txt += '<br />';
//txt += '<input type="button" value="'+CI.lang.language.create_event+'" />'
var btns = {};
btns[CI.lang.language.create_event] = true
btns[CI.lang.language.cancel] = false;
$.prompt(txt,{
prefix:'event_box',
callback: dodaj,
buttons: btns
});
function dodaj(v,m,f){
if(f && v){
var classN = getAjaxData('calendar/getClassJson/'+f.id_calendar);
var nEvent = {
title: f.title,
description: f.description,
location: f.location,
start: start,
end: end,
allDay: allDay,
className: classN,
id_calendar: f.id_calendar
};
if (f.title) {
calendar.fullCalendar('renderEvent',
nEvent,
false // make the event "stick"
);
}
addEvent(nEvent);
calendar.fullCalendar('refetchEvents');
}
calendar.fullCalendar('unselect');
}
},
这是addEvent函数,它使用JSON向db提交新数据:
function addEvent(event) {
var start = my_convertDate(new Date(event.start));
var end;
if(event.end === null) {
end = start;
} else {
end = my_convertDate(new Date(event.end));
}
if((event.allDay)){
event.allDay = 1
} else {
event.allDay = 0;
}
var eventData = {
start_date : start.date,
start_time : start.time,
end_date : end.date,
end_time : end.time,
id_event : event.id,
all_day : event.allDay,
title: event.title,
className: event.className,
location: event.location,
description: event.description,
id_calendar: event.id_calendar
}
makeAjaxRequest('event/addEventJson', eventData);
}