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

form modal doesn't open

Asked by Justin
4 years ago.

I made a context menu on event right click handling, everything seems fine, the modal prompt and the alert, but when i tried to open a form, it doesn't show at all, already tried making a simple one just to know if it works, also tried the sample script which was found on the tutorial screen and still nothing shows up, i wonder what seems to be the problem, here is the javascript i made,

var form = [
    {name: "Move From", id: "fromDate", dateFormat: "MMMM d, yyyy"},
    {name: "Move To", id: "toDate", dateFormat: "MMMM d, yyyy"}
];
dp.onEventRightClick = function(args){
    var id = args.e.id();
    var start = args.e.start();
    var end = args.e.end();
    var stat = args.e.resource();
    var data = {
        fromDate: start,
        toDate: end
    };
    dp.contextMenu = new DayPilot.Menu({
        items: [
            {text:"Accept Reservation", onclick: function() {
                    DayPilot.Modal.confirm("Do you want to accept reservation?",{ okText: "Yes", cancelText: "No" }).then(function(args){
                        if(args.result == "OK"){
                            var request = 3;
                            $.ajax({
                                url:'ajaxScript.php',
                                type:'post',
                                data:{req:request,SCHED_ID:id},
                                dataType:'json',
                                success:function(data){
                                    dp.events.load("schedules.php");
                                    dp.message(data.msg);
                                }
                            });
                        }
                    });
                } },
            {text:"Move schedule", onclick: function() {
                    DayPilot.Modal.form(form).then(function(args){
                        //i made an empty form with some fields
                    });
                }},
            {text:"Cancel Reservation", onclick: function() {
                    DayPilot.Modal.confirm("Are you sure you want to cancel reservation?",{ okText: "Yes", cancelText: "No" }).then(function(args){
                        if(args.result == "OK"){
                            var request = 2;
                            $.ajax({
                                url:'ajaxScript.php',
                                type:'post',
                                data:{req:request,SCHED_ID:id},
                                dataType:'json',
                                success:function(data){
                                    dp.events.load("schedules.php");
                                    dp.message(data.msg);
                                }
                            });
                        }
                    });
                }}
        ]});
}
Answer posted by Dan Letecky [DayPilot]
4 years ago.

This seems to work fine:

var form = [
  {name: "Move From", id: "fromDate", dateFormat: "MMMM d, yyyy"},
  {name: "Move To", id: "toDate", dateFormat: "MMMM d, yyyy"}
];

DayPilot.Modal.form(form).then(function(args){
  console.log(args);
});

Please make sure that you are using the latest DayPilot Pro version. The latest sandbox build (https://javascript.daypilot.org/sandbox/) includes the latest version of DayPilot.Modal (3.1.3).

This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.