最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to add a plain text in the header of a fullCalendar - Stack Overflow

programmeradmin1浏览0评论

I have used fullCalendar.js with the header content such as: today,month,year,prev,next and also made a custom add button, now I want to add a simple text in the header before the add button saying "Request new class", which will finally look like this: fullCalendar Header

now my header looks like it: my header

here is the code so far:

$('#sfullCalendar').fullCalendar({
  customButtons: {
        myCustomButton: {
            theme: 'true',
            text: '',
            click: function() {
                alert('clicked the custom button!');
            }
        }
    },
      defaultView: 'month',
      header: {
        left:   'today',
        center: 'title',
        right:  'prev,next myCustomButton'
      },
      });
<script src=".1.0/react.min.js"></script>
<script src=".1.0/react-dom.min.js"></script>
<script src=".1.1/jquery.min.js"></script>

I have used fullCalendar.js with the header content such as: today,month,year,prev,next and also made a custom add button, now I want to add a simple text in the header before the add button saying "Request new class", which will finally look like this: fullCalendar Header

now my header looks like it: my header

here is the code so far:

$('#sfullCalendar').fullCalendar({
  customButtons: {
        myCustomButton: {
            theme: 'true',
            text: '',
            click: function() {
                alert('clicked the custom button!');
            }
        }
    },
      defaultView: 'month',
      header: {
        left:   'today',
        center: 'title',
        right:  'prev,next myCustomButton'
      },
      });
<script src="https://cdnjs.cloudflare./ajax/libs/react/15.1.0/react.min.js"></script>
<script src="https://cdnjs.cloudflare./ajax/libs/react/15.1.0/react-dom.min.js"></script>
<script src="https://ajax.googleapis./ajax/libs/jquery/2.1.1/jquery.min.js"></script>

Share Improve this question asked Jan 15, 2017 at 7:00 ashfaqrafiashfaqrafi 5002 gold badges10 silver badges29 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 5

You can try:

    $('#calendar').fullCalendar({
  customButtons: {
    myCustomButton: {
      theme: 'true',
      text: '',
      click: function() {
        alert('clicked the custom button!');
      }
    }
  },
  defaultView: 'month',
  header: {
    left: 'today',
    center: 'title',
    right: 'prev,next myCustomButton'
  },
  eventAfterAllRender: function(view) {
    if ($('.label').length == 0) {
      $('.fc-myCustomButton-button').before('<div class="label">test</div>');
    }
  }
});

Fiddle

I was looking for something similar today, but in my case I just wanted to insert custom text in the center element of the toolbar, not extra buttons. After looking at the CSS for the header toolbar, I came up with this to put my text into the center of the toolbar (this is on version 5.3.0 of fullcalendar-scheduler, no idea if the CSS is the same on other versions):

.fc-header-toolbar > .fc-toolbar-chunk:nth-child(2)::before {
  font-size: 1.75em;
  content: 'My Custom Header Text';
}
发布评论

评论列表(0)

  1. 暂无评论