Move, resize, edit, add or delete appointments, then press Ctrl+Z to undo and Ctrl+Y to redo.

jQuery Scheduler: Undo and Redo

jqxScheduler records the changes made to its appointments - moved, resized, edited, added or deleted - so that they can be undone and redone with the undo and redo methods or with Ctrl+Z and Ctrl+Y.

A live JavaScript/jQuery example of jqxScheduler, the jQWidgets Scheduler component, with its complete source code below. It is one of 45 jqxScheduler demos for jQuery.

jqxScheduler API used in this demo

Source code

To run it in your own page, load jqx.base.css, a theme and the library files below from npm (npm install jqwidgets-scripts) or the jsDelivr CDN, then add the markup and the script. jQuery is not required: jqxcore.js provides $. Getting started with jqxScheduler shows the setup step by step.

The page loads jqx.base.css, a theme and these library files: jqxcore.js, jqxbuttons.js, jqxscrollbar.js, jqxdata.js, jqxdate.js, jqxscheduler.js, jqxscheduler.api.js, jqxdatetimeinput.js, jqxmenu.js, jqxcalendar.js, jqxtooltip.js, jqxwindow.js, jqxcheckbox.js, jqxlistbox.js, jqxdropdownlist.js, jqxnumberinput.js, jqxradiobutton.js, jqxinput.js.

It also loads helper scripts of this demo site, which are not part of the library: demos.js (getWidth() and other layout helpers).

script.js

$(document).ready(function () {
    var day = function (date, hour, minute) {
        return new Date(2026, 10, date, hour, minute || 0, 0);
    }
    var appointments = [
        { id: "review", subject: "Quarterly project review", calendar: "Room 1", start: day(17, 9), end: day(17, 12) },
        { id: "itgroup", subject: "IT group meeting", calendar: "Room 2", start: day(18, 10), end: day(18, 12) },
        { id: "course", subject: "Social media course", calendar: "Room 3", start: day(19, 13), end: day(19, 15) },
        { id: "planning", subject: "New projects planning", calendar: "Room 2", start: day(20, 9), end: day(20, 11) },
        { id: "interview", subject: "Interview with James", calendar: "Room 1", start: day(20, 14), end: day(20, 15) }
    ];

    var source =
    {
        dataType: "array",
        dataFields: [
            { name: 'id', type: 'string' },
            { name: 'subject', type: 'string' },
            { name: 'calendar', type: 'string' },
            { name: 'start', type: 'date' },
            { name: 'end', type: 'date' }
        ],
        id: 'id',
        localData: appointments
    };
    var adapter = new $.jqx.dataAdapter(source);

    $("#scheduler").jqxScheduler({
        date: new $.jqx.date(2026, 11, 18),
        width: '100%',
        height: 560,
        source: adapter,
        view: 'weekView',
        showLegend: true,
        // the defaults, written out: changes are recorded, up to the last 100
        undoRedo: true,
        undoRedoLimit: 100,
        // the meetings have times: no all-day row
        showAllDayRow: false,
        ready: function () {
            $("#scheduler").jqxScheduler('scrollToTime', 8);
        },
        resources:
        {
            colorScheme: "scheme05",
            dataField: "calendar",
            source: new $.jqx.dataAdapter(source)
        },
        appointmentDataFields:
        {
            from: "start",
            to: "end",
            id: "id",
            subject: "subject",
            resourceId: "calendar"
        },
        views: [
            { type: 'dayView', timeRuler: { formatString: 'HH:mm' } },
            { type: 'weekView', timeRuler: { formatString: 'HH:mm' } },
            'monthView'
        ]
    });

    $("#undo").jqxButton({ width: 80, disabled: true });
    $("#redo").jqxButton({ width: 80, disabled: true });
    $("#undo").on('click', function () {
        $("#scheduler").jqxScheduler('undo');
    });
    $("#redo").on('click', function () {
        $("#scheduler").jqxScheduler('redo');
    });

    // the buttons follow what there is to undo and redo
    $("#scheduler").on('undoRedoChange', function (event) {
        $("#undo").jqxButton({ disabled: !event.args.canUndo });
        $("#redo").jqxButton({ disabled: !event.args.canRedo });
    });

    var log = function (text) {
        $("#log").prepend($("<div></div>").text(new Date().toLocaleTimeString() + "  " + text));
    }
    var describe = function (appointment) {
        return "“" + appointment.subject + "” " + appointment.from.toString('ddd HH:mm') + "-" + appointment.to.toString('HH:mm');
    }
    // event.args.action says when undo or redo caused the change
    $("#scheduler").on('appointmentChange', function (event) {
        log((event.args.action ? event.args.action + ": " : "") + "changed " + describe(event.args.appointment));
    });
    $("#scheduler").on('appointmentAdd', function (event) {
        log((event.args.action ? event.args.action + ": " : "") + "added " + describe(event.args.appointment));
    });
    $("#scheduler").on('appointmentDelete', function (event) {
        log((event.args.action ? event.args.action + ": " : "") + "deleted " + describe(event.args.appointment));
    });
});

body.html

<div id="content" class="demo">
<div class="demo-bar">
    <input type="button" id="undo" value="Undo">
    <input type="button" id="redo" value="Redo">
    <span class="hint">Move, resize, edit, add or delete appointments, then press Ctrl+Z to undo and Ctrl+Y to redo.</span>
</div>
<div id="scheduler"></div>
<div id="log" class="demo-log" aria-label="Changes" aria-live="polite"></div>

</div>

Learn more

More jQuery Scheduler demos