Hi,
I have defined a class, so simply create an object class and call the method dpinit().
Alberto
class CalendarPilot
{
constructor(InsertEvent,SelectStartDate)
{
this.InsertEvent=InsertEvent;
this.SelectStartDate=SelectStartDate;
//this.dpDiv = document.getElementById('dp');
this.dp=new DayPilot.Month('dp');
this.dp.cellMode=true;
this.dp.viewType="Weeks";
this.dp.weeks=1;
this.dp.locale="it-ch";
this.dp.allDayend="Date";
this.dp.onTimeRangeSelected = (args) =>
{
if (this.InsertEvent !== undefined)
this.InsertEvent(args.start, args.end);
else
alert(`InsertEvent value: "${args.start}". Missing InsertEvent function in constructor.`);
};
this.Navdp=new DayPilot.Navigator('nv');
this.Navdp.selectMode = "week";
this.Navdp.locale="it-ch";
this.Navdp.onTimeRangeSelected = (args) =>
{
if (this.SelectStartDate !== undefined)
this.SelectStartDate(args.start);
else
alert(`SelectStartDate value: "${args.start}". Missing SelectStartDate function in constructor.`);
};
}
dpAddEvent(evstart,evend,EventText)
{
this.dp.clearSelection();
if (!EventText) return;
var e = new DayPilot.Event({
start: evstart,
end: evend,
id: DayPilot.guid(),
text: EventText
});
this.dp.events.add(e);
}
dpInit()
{
//this.dp.minCellHeight=300;
//this.dp.startDate = DayPilot.Date.today().addDays(7);
//this.dp.width="95%";
this.dp.init();
this.Navdp.init();
}
dpUpdate(startDate)
{
this.dp.startDate = startDate;
this.dp.update();
}
}