search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Monthly Calendar Monthname title with Navigator

Asked by Martin
6 years ago.

Dear daypilot Team,

Created this code for the navigation:
<a href="javascript:dp.startDate = dp.startDate.addMonths(-1); dp.update();navigator.onTimeRangeSelected();" class="btn btn-default btn-xs"><i class="fa fa-angle-double-left"></i></a>

<a href="javascript:dp.startDate = new DayPilot.Date('2015-09-01'); dp.update();" class="btn btn-default btn-xs"><i class="fa fa-angle-double-up"></i></a>

<a href="javascript:dp.startDate = dp.startDate.addMonths(1); dp.update();" class="btn btn-default btn-xs"><i class="fa fa-angle-double-right"></i></a>

Put this code in the calender script:
navigator.onTimeRangeSelected = function(args) {
$("#label").html("MMMM yyyy"));

But the browser console shows this error:
TypeError: args is undefined

Has anyone implemented something like this?
Or do I have the possibility to highlight the monthname in the calendar?


Answer posted by Dan Letecky [DayPilot]
6 years ago.

The problem is that you are manually calling onTimeRangeSelected without any parameter.

Take a look at the source of this page:

This is the best way to synchronize next/previous buttons with the navigator, the month control and the label.

The buttons update the navigator using .select() and the navigator updates the month control and the label automatically.

<div style="margin-left: 150px;">
    <div class="space">
        <a href=";">&lt;</a>
        <span id="label" style="display: inline-block; width: 100px; text-align:center;"></span>
        <a href=";">&gt;</a>

    <div id="dp"></div>

<script type="text/javascript">

    var nav = new DayPilot.Navigator("nav");
    nav.showMonths = 3;
    nav.selectMode = "month";
    nav.onTimeRangeSelected = function(args) {
        dp.startDate = args.start;
        $("#label").html("MMMM yyyy"));
    var dp = new DayPilot.Month("dp");
    // ...
Comment posted by Martin
6 years ago.

Many thanks Dan.
Your hint solved my problem.

This question is more than 3 months old and has been closed. Please create a new question if you have anything to add.