Skip to content

Usage docs should explain how to use eventsThisInterval #356

@nk9

Description

@nk9

If you have specified a 3-month lengthOfTime, the object your template gets from eventsThisInterval is an array of arrays. The sample template code which iterates eventsThisMonth expecting to encounter events won't work; you have to nest a second _.each() inside the first to access the event objects.

$('#mycal').clndr({
	lengthOfTime: {
		months: 3,
		interval: 3,
		startDate: "2020-09-01"
	},
	events: [
		{
			title: "Birthday party",
			date: "2020-07-24",
			type: "vbm"
		}, {
			title: "Fireworks",
			date: "2020-07-04",
			type:  "registration"
		}
	// […]
	]
});

And so your template needs to do:

<div class="events">
	<% _.each(eventsThisInterval, function(month) {
		_.each(month, function(event) { %>
			console.log("<%= event %>");
			<div class="event-item">
				<div class="event-item-title"><%= event.title %></div>
			</div>
		<% });
	}); %>
</div>

It would be helpful if the usage docs in the README explained this, or even mentioned it. I'm not sure what the situation is with interval lengths other than a month, but that's something to mention if it's different again.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions