2011-05-24 78 views
0

這聽起來相當簡單,但您如何傳遞SELECT函數的變量來填充div格式?FullCalender - 將選擇函數傳遞給Div

我已經成功設置FC並使用SELECT功能來觸發窗體「new_event」的外觀。

select: function(startDate, endDate, allDay, jsEvent, view) { 
$("#new_event").show(); 
}, 

我現在需要填充起始日期等形式一旦完成,則表格將通過PHP MySQL後端進行必要的修改。

任何幫助將不勝感激。

cmury

回答

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函數提交新的數據使用到DB JSON:

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); 
}