2016-03-21 18 views
-1

Ich benutze drblue: fullcalendar. Anzeige funktioniert gut, aber ich kann keine Art von Ereignis zu arbeiten. Ich habe verschiedene ausprobiert. Im folgenden Codeausschnitt habe ich den Ladevorgang versucht:meteor fullcalendar reagiert überhaupt nicht auf Ereignisse

Template.Schedule.helpers({ 
    calendarOptions: { 
     // Standard fullcalendar options 
     schedulerLicenseKey: 'CC-Attribution-NonCommercial-NoDerivatives', 
     slotDuration: '01:00:00', 
     minTime: '07:00:00', 
     maxTime: '22:00:00', 
     lang: 'en', 
     defaultView: 'agendaWeek', 
     contentHeight: 500, 
     firstDay: 1, 
     timeFormat: 'HH:mm', 
     timezone: 'UTC', 
     selectable: true, 
     // Function providing events reactive computation for fullcalendar plugin 
     events: function(start, end, timezone, callback){ 

      var events = []; 

       Assignments.find().map(function(doc){ 

        var startTimeHours = Number(doc.time.substr(0, 2)); 
        var startTimeMinutes = Number(doc.time.substr(3, 2)); 

        var startDateTime = new Date(doc.date); 
        startDateTime.setHours(startDateTime.getHours() + startTimeHours); 
        startDateTime.setMinutes(startDateTime.getMinutes() + startTimeMinutes); 

        var endDateTime = new Date(doc.date); 

        var effort = doc.state == 'finished' ? doc.realEffort : doc.effort; 

        endDateTime.setHours(startDateTime.getHours() + effort); 
        endDateTime.setMinutes(startDateTime.getMinutes()); 

        var getColorForState = function(state) 
        { 
         switch(state) 
         { 
          case 'finished': return '#00bb00'; 
         } 
         return '#1197C1'; 
        }; 

        var getBorderColorForState = function(state) 
        { 
         switch(state) 
         { 
          case 'finished': return '#009900'; 
         } 

         return '#004781'; 
        }; 

        return{ 
        id: doc.title, 
        start: startDateTime, 
        end: endDateTime, 
        title: doc.title, 
        backgroundColor: getColorForState(doc.state), 
        borderColor: getBorderColorForState(doc.state) 
       } 
      }).forEach(function(event){ 

       events.push(event); 
      }); 
callback(events); 
     }, 
     // Optional: id of the calendar 
     id: "calendar1", 
     // Optional: Additional classes to apply to the calendar 
     addedClasses: "col-md-12" 
     // Optional: Additional functions to apply after each reactive events computation 

    } 
    }); 

Template.Schedule.events({ 
    loading: function(isLoading, view){ 
     console.log('hi'); 
    } 

}); 

Keine JS Fehler auf Client oder Server und keinen Protokolleintrag, auch nicht. Ich habe auch DayClick versucht, Select und ClickEvent, aber ich bekomme keinen Log-Eintrag. Wenn ich eine alert hineinlege bekomme ich auch nichts.

Antwort

0

Nicht sicher, warum downvoted, wenn Sie weitere Informationen oder Details benötigen, bitte geben Sie es an.

Wie auch immer, ich konnte es lösen. Dort gab es einige „falsche“ Code und ich fand kein Beispiel, aber funktioniert es, wenn ich nur hinzufügen, das entsprechende Ereignis an den Optionen, d.h .:

Template.Schedule.helpers({ 
    calendarOptions: { 
     // all the various options 
     eventClick: function(event, jsEvent, view){ 
      alert(event.title + "\r\n\r\n" + event.description); 
     }, 
Verwandte Themen