jquery fullcalendar使用JSON发送自定义参数和刷新日历 [英] jquery fullcalendar send custom parameter and refresh calendar with JSON

查看:279
本文介绍了jquery fullcalendar使用JSON发送自定义参数和刷新日历的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

试图使用jquery fullcalendar。事件数据来自使用JSON的服务器。
我的页面有一个下拉式元素和fullcalendar div。



我需要的是每次用户更改下拉菜单时刷新日历。为了获取新的事件数据,下拉列表中选定的值应该发布到服务器上。

以下是我的代码

  $(document).ready(function(){
$('#calendar')。fullCalendar({
events:{
url:'/ myfeed',
data:{personId:$('#personDropDown')。val()}
}
});

$( '#personDropDown')。change(function(){
$('#calendar')。fullCalendar('refetchEvents');
});

});

上述代码不起作用。
任何帮助?

解决方案

试试这个:

  $(document).ready(function(){
$('#calendar')。fullCalendar({
events:{
url:'/ myfeed',
data:function(){//返回一个对象的函数
return {
personId:$('#personDropDown')。val(),
$;


});


$('#personDropDown')。change(function(){
$('#calendar')。fullCalendar('refetchEvents');
});

});


im trying to use the jquery fullcalendar. The event data comes from the server using JSON. My page has a dropdown element and the fullcalendar div.

What i need is to refresh the calendar each time the user changes the dropdown. The selected value of the dropdown should be posted to the server in order to fetch the new event data

Here is my code

     $(document).ready(function() {
        $('#calendar').fullCalendar({
            events: {
                url : '/myfeed',
                data : {personId : $('#personDropDown').val() }
            }
        });

        $('#personDropDown').change(function(){
            $('#calendar').fullCalendar('refetchEvents');
        });

    });

The code above however doesnt work. Any help?

解决方案

try this:

$(document).ready(function () {
    $('#calendar').fullCalendar({
        events: {
            url: '/myfeed',
            data: function () { // a function that returns an object
                return {
                    personId: $('#personDropDown').val(),
                };

            }
        });


    $('#personDropDown').change(function () {
        $('#calendar').fullCalendar('refetchEvents');
    });

});

这篇关于jquery fullcalendar使用JSON发送自定义参数和刷新日历的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆