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

onTimeRangeSelected(args) not passing values

Asked by Mike
10 years ago.

This is actually a Day Pilot for JavaScript question. I'm using the Day Pilot JavaScript API to create a calenda,r and I'd like to be able to create a new event by selecting a time range on the calendar. I used the example from this link http://api.daypilot.org/daypilot-month-ontimerangeselected/ but when I try to use args.start inside my event creating function, I get "undefined".

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

The client-side event-handling API has two modes that can be switched using .api property:

http://api.daypilot.org/daypilot-scheduler-api/

All DayPilot versions that include an integrated server-side part (ASP.NET WebForms, MVC, Java) use .api=1. These versions will support api=2 in the near future but at this moment you can only use api=1 (api=2 will break the event handlers set from the server side).

You should check the bottom of the API doc page for the api=1 syntax:

http://api.daypilot.org/daypilot-scheduler-ontimerangeselected/

The standalone JavaScript version uses .api=2 by default and the following example will work. It is copied from the demo at http://javascript.daypilot.org/demo/scheduler/

    dp.onTimeRangeSelected = function (args) {
        var name = prompt("New event name:", "Event");
        dp.clearSelection();
        if (!name) return;
        var e = new DayPilot.Event({
            start: args.start,
            end: args.end,
            id: DayPilot.guid(),
            resource: args.resource,
            text: name
        });
        dp.events.add(e);
        dp.message("Created");
    };
This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.