Passing FullCalendar date to my dialog box modal form

前提是你 提交于 2020-01-15 03:53:51

问题


I'm using fullcalendar and what I want is that the date clicked be passed to a dialog box modal form(asp.net mvc PartialView). This is my code right now:

 $calendar.fullCalendar({

        events: "/Home/CalendarData",
        dayClick: function (date) {
            $calendar.fullCalendar("renderEvent", { title: "on process", start: date}, true);

            $("#editDialog").html('')
            .load("/Home/About", function () {
                $("#editDialog").data("value", date).dialog("open");
            });
        }
    });

As you see i already tried passing a value to my dialog using data() function. Is there a way for my PartialView to access that data?


回答1:


You should be able to pass a json payload using the second parameter of the $.load

for example

$calendar.fullCalendar({
        events: "/Home/CalendarData",
        dayClick: function (date) {
            $calendar.fullCalendar("renderEvent", { title: "on process", start: date}, true);

           var payLoad = {
              ‘selectedDate’ : date
           };

            $("#editDialog").html('')
            .load("/Home/About", payLoad, function () {
                $("#editDialog").data("value", date).dialog("open");
            });
        }
    });

In the above example, we are creating a json object by the name of payLoad and passing it in via $.load method. Now you can define a variable by the name selectedDate on your controller action and capture the value



来源:https://stackoverflow.com/questions/15053390/passing-fullcalendar-date-to-my-dialog-box-modal-form

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!