2012-03-13 40 views
0

我想顯示具有相同事件ID的週期性事件的eventmouseover事件上的事件描述的工具提示,但我只想載入實際描述json在事件的第一次發生時提供反饋。有關具有相同ID的週期性事件的工具提示描述

想要這樣做的原因是因爲某些事件描述可能會很長,而且我不想加載完全相同的段落100次或更多,並通過網絡發送,如果我只能訪問第一個事件的描述,並在我將鼠標懸停在任何重複事件的工具提示中時顯示。

我的日曆初始化代碼:

$('#calendar').fullCalendar({ 
header: { 
left: 'prev,next today', 
center: 'title', 
right: 'month,agendaWeek,agendaDay' 
}, 
editable: false, 
allDayDefault: false, 
events: "https://json_feed_url", 
eventMouseover: function(e,m){ 
    var tPosX = m.pageX - 5 ; 
    var tPosY = m.pageY + 20 ; 
    $('#tooltip').css({top: tPosY, left: tPosX, display: 'block'}); 
    var tt = ''; 
    tt += e.id+'<br />'; 
    $('#tooltip').html(tt); 
}, 
eventMouseout: function(){ 
    $('#tooltip').css({display: 'none'}); 
}, 
loading: function(bool){ 
    if (bool) $('#loading').show(); 
    else $('#loading').hide(); 
} 
}); 

和我的JSON數據料會像這樣:

[ 
{ 
    "id": 0, 
    "title": "Study Hall", 
    "start": "2012-01-09T15:00", 
    "end": "2012-01-09T16:15", 
    "color": "green", 
    "description": "Discuss formal language theory and abstract machines" 
}, 
{ 
    "id": 0, 
    "title": "Study Hall", 
    "start": "2012-01-11T15:00", 
    "end": "2012-01-11T16:15", 
    "color": "green", 
    "description": "" 
}, 
{ 
    "id": 0, 
    "title": "Study Hall", 
    "start": "2012-01-16T15:00", 
    "end": "2012-01-16T16:15", 
    "color": "green", 
    "description": "" 
}, 
{ 
    "id": 0, 
    "title": "Study Hall", 
    "start": "2012-01-18T15:00", 
    "end": "2012-01-18T16:15", 
    "color": "green", 
    "description": "" 
}, 
{ 
    "id": 0, 
    "title": "Study Hall", 
    "start": "2012-01-23T15:00", 
    "end": "2012-01-23T16:15", 
    "color": "green", 
    "description": "" 
}, 
{ 
    "id": 0, 
    "title": "StudyHall", 
    "start": "2012-04-25T15: 00", 
    "end": "2012-04-25T16: 15", 
    "color": "green", 
    "description": "" 
} 
] 

也能正常工作的情況下的非常第一次出現,但其餘的事件說明在工具提示中全部爲空。有沒有人有引用第一次出現的解決方案?

謝謝

回答

0

我使用對話框解決了eventMouseOver中的問題。我設置了一個對話框,其中包含適當的元素,然後根據需要設置適當的值。您可以提前設置這些值,或者在頁面加載時設置這些值。 (不是說我的代碼有2種不同的約會來自兩種不同的來源,所以eventType是「appt」,在這種情況下經過測試。

eventMouseover: function(calEvent, jsEvent, view){ 
    if(calEvent.eventType == "appt") 
     { 
     $('#eventDetails').dialog({title: calEvent.title}); 
     $('#eventDetails').dialog('open'); 
     var myDialogX = jsEvent.pageX + 10; 
     var myDialogY = jsEvent.pageY + 10; 
     $('#eventDetails').dialog('option', 'position', [myDialogX, myDialogY]); 
     $('#appointmentTypeName').append(calEvent.appointmentTypeName); 
     $('#appointmentReason').append(calEvent.appointmentReason); 
     $('#appointmentTime').append(calEvent.start); 
     $('#appointmentTitle').append(calEvent.appointmentTitle); 
     $('#appointmentFacility').append(calEvent.facilityName); 
     } 
     },