$(document).ready(function(){
    var appointments = $('.appointments');
    appointments.on('click', '.next', function (e) {
        e.preventDefault();

        var key = $(this).data('key');
        $.ajax({
            type: "POST",
            url: Routing.generate('app_doctor_homepage'),
            data: {
                'date': key
            }
        })
        .done(function (data) {
            if (typeof(data.status) != "undefined" && data.status == "ok") {
                $('.appointments').html(data.content);
            }
        })
    });

    appointments.on('click', '.preview', function (e) {
        e.preventDefault();

        var key = $(this).data('key');
        $.ajax({
            type: "POST",
            url: Routing.generate('app_doctor_homepage'),
            data: {
                'date': key
            }
        })
            .done(function (data) {
                if (typeof(data.status) != "undefined" && data.status == "ok") {
                    $('.appointments').html(data.content);
                }
            })
    });
});
