2011-06-01 46 views
2

我有幾個關於通過arshaw的fullcalendar查詢..如圖更新事件動態

  1. 當我選擇日期的特定的拉伸,並給予適當的標題

    here 我得到的渲染事件日曆..但是當我想保存事件(我使用的是asp.net),即說用戶點擊保存按鈕後,必須將title,startdate,end date寫入腳本的events[{}] ....for這即時通訊使用 response.write("script /script(with the tags of course)")按鈕點擊後沒有工作..會有人建議更好或更簡單的工作方式?

  2. 如何禁用selectable屬性?例如,只有管理員可以設置事件和用戶只能看到該事件並不能編輯它..

回答

1

我不認爲你可以更新的Response.Write()方法fullcalendar事件的JavaScript對象。

您應該使用ajax在服務器端保存事件並更新客戶端的日曆。 做這樣的事情

function saveEvent() { 

    var event = { startDate: $('#txtDate').val(), description: $('#txtDescription').val(), id: id } 


    $.ajax({ 
     type: "POST", 
     async: false, 
     url: "../UserCalendarService.asmx/SaveEvent", 
     data: "{'startDate': '" + event.startDate + "','description':'" + event.description + "','id':'" + event.id + "'}", 
     contentType: "application/json; charset=utf-8", 
     dataType: "json", 
     success: function (result) { 
      result = result.d; 
      eventFound = $('#calendar').fullCalendar('clientEvents', result.id).length; 
      if (eventFound == 1) { 
       existingEvent = $('#calendar').fullCalendar('clientEvents', result.id); 
       existingEvent[0].title = result.title; 
       existingEvent[0].start = result.start; 
       existingEvent[0].editable = result.editable; 
       existingEvent[0].allday = true; 
       $('#calendar').fullCalendar('updateEvent', existingEvent[0]); 
      } 
      else { 
       $('#calendar').fullCalendar('renderEvent', { 
        title: result.title, 
        start: result.start, 
        id: result.id, 
        editable: result.editable, 
        allday: true 
       }, 
      false // make the event "stick" 
      ); 
      } 
     }, 
     error: function (xhr, status, error) { 
      var err = eval("(" + xhr.responseText + ")"); 
      if (err.Message == 'SomeErrorMessage') { 
       //handleError, redirect or popup message 
      } 
     } 
    }); 

} 

關於你的第二個問題,事件對象有可編輯的屬性。這是真的或假的。 你可以在適當的documentation找到更多關於它的信息。

+0

謝謝你的回覆!好吧,我明白髮生了什麼,但你也可以發佈服務器端代碼?即.asmx文件的內容.. – anuguy 2011-06-03 12:11:33

+0

它只是一個Web服務,它返回來自服務器的事件對象列表(列表),注意到它的特殊性 – nemke 2011-06-04 06:02:55