簡體   English   中英

使用meteor.js設置全日歷

[英]Set a fullcalendar with meteor.js

我是新來的流星,並且我正在嘗試設置完整的日歷。 我正在使用Windows,並且我在meteor add fullcalendar:fullcalendar但是我無法渲染fullcalendar ...到目前為止,我已經閱讀了很多教程,但仍然一無所獲。 這是即時通訊使用的代碼示例。 我不知道是否有辦法檢查fullcalendar軟件包是否確實安裝在我的應用中...還是我必須導入它...

main.js

import { Template } from 'meteor/templating';
import { Notes } from '../lib/collections.js';
//import { fullCalendar} from 'fullcalendar';
//import { moment } from 'moment';


import './main.html';

Template.body.helpers({
 /*
  notes:[
    {text: 'My note 1'},
    {text: 'My note 2'},
    {text: 'My note 3'}
  ]
  */

  notes(){
    return Notes.find({});
  }
});


Template.add.events({
  'submit .add-form': function(){
    event.preventDefault();

    //get input value
    const target = event.target;
    const text = target.text.value;

    //insert note into collection
    Notes.insert({
      text,
      createdAt: new Date()
    });

    //clear the form
    target.text.value = '';

    //close the modal
    $('#modal1').modal('close');

    return false;
  }
});

Template.note.events({
 'click .delete-note': function(){
   Notes.remove(this._id);
   return false;
 }
});

Template.calendar.onRendered()({
 $('#calendario').fullCalendar();
})

main.html

<head>
  <title>note manager</title>
   <!-- Compiled and minified CSS -->
   <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.2/css/materialize.min.css">
   <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
   <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.3.1.min.js"></script>
   <script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.2/js/materialize.min.js"></script>
</head>

<body>

<nav class="red">
  <div class="container">
    <div class="nav-wrapper">
      <a href="#" class="brand-logo">Danillo</a>
      <ul id="nav-mobile" class="right hide-on-med-and-down">
        <li class="nav-item">
            <a class="waves-effect waves-light btn modal-trigger" href="#modal1"> ADD Modal</a>
        </li>
      </ul>
    </div>
  </div>
</nav>
  <div class="container">
      <h1>Nomes</h1>
      <ul class="collection">
      {{#each notes}}
      {{> note}}
      {{/each}}
    </ul>
  </div>


  {{>add}}

  {{>calendar}}



  <script>
      $(document).ready(function(){
          // the "href" attribute of the modal trigger must specify the modal ID that wants to be triggered
          $('.modal').modal();
        });
        </script>

</body>

<template name="note">
  <li class="collection-item">
    {{text}}
    <a href="#" class="delete-note secondary-content"><i class="material-icons">close</i></a>
  </li>
</template>

<template name="add">
    <div id="modal1" class="modal">
        <div class="modal-content">
         <h3>Add Nome</h3>
         <form class="add-form">
           <input type="text" name="text" placeholder="Add Nome...">
         </form>
        </div>
      </div>

</template>

<template name ="calendar">
  <div class="container">
    <div id="calendario">
    </div>
  </div>
</template>

多謝你們!

Template.TemplateName.rendered = function()  

函數,您必須定義所有喜歡的東西,例如:eventRender,dayClick,eventAfterRender,viewRender,eventClick等

我在Template.TemplateName.rendered = function()中使用的示例代碼

$('#calendar').fullCalendar({
    //height: "auto",
    minTime: OpenTime,
    maxTime: closeTime,
    slotDuration: '00:15:00',
    timezone: "Asia/Colombo",
    allDaySlot:false,
    dayOfMonthFormat: 'ddd - DD MMM',

    defaultView: 'multiColAgendaDay',
    views: {
        multiColAgendaDay: {
            // disabledColumns: [1],
            type: 'multiColAgenda',
            duration: { days: 1 },
            numColumns: 7,
            columnHeaders: stylistDetails,
            /* disabledColumns: [1] */
        }
    },
    scrollTime: '09:00:00',
    allDaySlot: false,
   /* header: {
   left: 'multiColAgendaDay',
   center: 'title',
   right: 'today prev,next'
   }, */

  header:false, 
  dayOfMonthFormat: 'ddd - DD MMM',

  events( start, end, timezone, callback ) {
let filterBranchId = Session.get("filterBranchId");

let data = AppointmentsServices.find({branchId:filterBranchId,stylistDisabled: {$ne: true}}).fetch().map( ( event ) => {

return event;
}); 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM