{"id":7932,"date":"2015-11-10T12:43:41","date_gmt":"2015-11-10T12:43:41","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2015\/11\/10\/jquery-fullcalendar-send-custom-parameter-and-refresh-calendar-with-json-open-source-projects-arshaw-fullcalendar\/"},"modified":"2015-11-10T12:43:41","modified_gmt":"2015-11-10T12:43:41","slug":"jquery-fullcalendar-send-custom-parameter-and-refresh-calendar-with-json-open-source-projects-arshaw-fullcalendar","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2015\/11\/10\/jquery-fullcalendar-send-custom-parameter-and-refresh-calendar-with-json-open-source-projects-arshaw-fullcalendar\/","title":{"rendered":"jquery fullcalendar send custom parameter and refresh calendar with JSON-open source projects arshaw\/fullcalendar"},"content":{"rendered":"<p>I have a problem of duplication events. When I create an event always the last event is duplicate. I am required to use location.reload() to avoid that.Someone can help me find a solution. This is my code :<\/p>\n<pre><code>$(document).ready(function() {\n\n            var date = new Date();\n            var d = date.getDate();\n            var m = date.getMonth();\n            var y = date.getFullYear();\n\n\n\n\n            \/* initialize the calendar\n            -----------------------------------------------------------------*\/\n\n            var calendar = $('#calendar').fullCalendar({\n                allDayDefault: false,\n                minTime: 7,\n                maxTime: 20,\n                editable: true,\n                ignoreTimezone: false,\n\n                header: {\n                    left: 'prev,next today',\n                    center: 'title'\n                    \/\/right: 'resourceDay,month,agendaWeek',\n                    \/\/right: 'resourceDay'\n                },\n                titleFormat: 'ddd, MMM dd, yyyy',\n                defaultView: 'resourceDay',\n\n                resources: [\n                    {\n                        name: 'David Boudreau',\n                        id: '71'\n                    },\n                    {\n                        name: 'Fr\u00e9d\u00e9ric Cyr',\n                        id: '50'\n\n                    },\n                    {\n                        name: 'Guillaume R.',\n                        id: '12'\n                    }\n                    ,\n                    {\n                        name: 'Jonathan Morin',\n                        id: '58'\n                    }\n                    ,                                               \n                ],\n\n                events: \"\/events.php\",\n\n                \/\/ affiche img done pour chaque event\n                 eventRender: function(event, element) {\n                    if(event.done == 1)\n                    {\n                        $('#fc-event-done_'+event.id).show();\n                    }\n                },\n\n                \/*add event*\/\n                selectable: true,\n                selectHelper: true,\n                select: function(start, end, allDay, event, resourceId) {\n\n                start = $.fullCalendar.formatDate(start, \"yyyy-MM-dd HH:mm:ss\");\n                end = $.fullCalendar.formatDate(end, \"yyyy-MM-dd HH:mm:ss\");\n\n                 $(\"#name_title\").html('<\/code><\/pre>\n<h3 id=\"myModalLabel\"><code>Nouvelle T\u00e2che<\/code><\/h3>\n<pre>');\n                 $('#duree').hide();\n                 $('#del').hide();\n                 $('#myModal').modal('show');\n                 $('#title_tache').focus();\n                 var data  = '';\n\n                 $(\"#submit\").click(function(){  \n                     var title = $('#title_tache').val();\n                     var color = $('input[name=lst_type]:checked').val();\n                     var datefin = $('#datepicker').val();\n\n\n                     $.ajax({\n                         url: 'add_events.php',\n                         data: 'title='+ title+'&amp;start='+ start +'&amp;end='+ end +'&amp;color='+ color +'&amp;datefin='+ datefin +'&amp;resourceId=' + resourceId,\n                         type: \"POST\",\n                         success: function(data) {\n\n                            $(\"#tacheform\").trigger('reset'); \/\/jquery \n                             $('#myModal').modal('hide');\n\n                             $(\"#calendar\").fullCalendar('refetchEvents');\n                              $(\"#calendar\").fullCalendar('unselect');\n\n                             \/\/location.reload();\n                         }\n                     });\n\n                 });\n                 \/\/$(\"#tacheform\").trigger('reset'); \/\/jquery \n                $(\"#calendar\").fullCalendar('unselect');\n\n                },\n\n                \/*edit info event*\/\n                eventClick: function(calEvent, jsEvent, view) {\n                 \/\/console.log('dentro eventClick');\n                    $(\"#name_title\").html('<\/pre>\n<h3 id=\"myModalLabel\"><code>Mise \u00e0 jour<\/code><\/h3>\n<pre>');\n                    $('#myModal').modal('show'); \n                    $('#title_tache').val(calEvent.title);\n                    $('#datepicker').val(calEvent.datefin);\n                    \/\/console.log(calEvent.done);\n                    if(calEvent.done == 1){ $('#done').prop('checked', true);}\n                    else{$('#done').prop('checked', false);}\n\n\n                     start1 = $.fullCalendar.formatDate(calEvent.start, \"yyyy-MM-dd HH:mm:ss\");\n                     end1 = $.fullCalendar.formatDate(calEvent.end, \"yyyy-MM-dd HH:mm:ss\");\n                     Id = calEvent.id;\n                     resource =  calEvent.resourceId;\n                     bdcolor = calEvent.backgroundColor;\n                     \/*select color from database*\/\n                     if(bdcolor != ''){ \n                        if(bdcolor == '#f39c11'){$(\"#lst_type1\").prop(\"checked\", true); }else{$(\"#lst_type1\").prop(\"checked\", false);}\n                        if(bdcolor == '#2ecd71'){$(\"#lst_type2\").prop(\"checked\", true); }else{$(\"#lst_type2\").prop(\"checked\", false);}\n                        if(bdcolor == '#5cade2'){$(\"#lst_type3\").prop(\"checked\", true); }else{$(\"#lst_type3\").prop(\"checked\", false);}\n                     }\n\n\n                     \/*calcul hours for event*\/ \n                     duration  = timediff(calEvent.start,calEvent.end);\n                     $('#duration').val(duration);\n\n\n                     \/\/update event\n                     $(\"#submit\").click(function(){            \n                        var title1 = $('#title_tache').val();\n                        var color = $('input[name=lst_type]:checked').val();\n                        var datefin = $('#datepicker').val();\n                        var done = 0;\n\n                        if( $('#done').is(':checked') ){\n                            done = $('#done').val();\n                        }\n                        \/\/calEvent.title =title;\n                         $.ajax({\n                            type: \"POST\",\n                            url: \"update_events.php\",\n                            data: 'title='+ title1+'&amp;start='+ start1 +'&amp;end='+ end1 +'&amp;resourceId='+ resource +'&amp;color='+ color +'&amp;datefin='+ datefin +'&amp;done='+ done + '&amp;id=' + Id,\n                                success: function(data){\n                                      \/\/$(\"#thanks\").html(msg)\n                                    $(\"#tacheform\").trigger('reset'); \/\/jquery \n                                     $('#myModal').modal('hide');\n                                     $(\"#calendar\").fullCalendar('refetchEvents');\n                                     calendar.fullCalendar('unselect');\n                                     location.reload();\n\n                                },\n                            error: function(){alert(\"Erreur lors de l'update\");}});\n                     });\n\n                    \/\/delete event\n                     $(\"#del\").click(function(){            \n                         $.ajax({\n                            type: \"POST\",\n                            url: \"delete_event.php\",\n                            data: 'id=' + Id,\n                                success: function(data){\n                                      \/\/$(\"#thanks\").html(msg)\n                                    \/\/$(\"#tacheform\").trigger('reset'); \/\/jquery  \n                                    $(\"#myModal\").modal('hide');\n                                    $(\"#calendar\").fullCalendar('refetchEvents');\n                                    calendar.fullCalendar( 'unselect');\n\n                                },\n                            error: function(){alert(\"Erreur lors delete\");}});\n                     });\n                    calendar.fullCalendar( 'unselect');\n                },\n                \/*update event*\/\n                editable: true,\n                eventDrop: function(event, delta) {\n                 start = $.fullCalendar.formatDate(event.start, \"yyyy-MM-dd HH:mm:ss\");\n                 end = $.fullCalendar.formatDate(event.end, \"yyyy-MM-dd HH:mm:ss\");\n                 datefin  = event.datefin;\n                 done  = event.done;\n                 resource =  event.resourceId;\n                 $.ajax({\n                 url: 'update_events.php',\n                 data: 'title='+ event.title+'&amp;start='+ start +'&amp;end='+ end +'&amp;resourceId='+ resource +'&amp;color='+ event.backgroundColor+'&amp;datefin='+datefin+'&amp;done='+done+'&amp;id='+ event.id ,\n                 type: \"POST\",\n                 success: function(json) {\n                 \/\/alert(\"OK\");\n                 \/\/console.log('update drop'); \n                   $.pnotify({\n                        title: 'Mise \u00e0 jour r\u00e9ussi',\n                        type: 'success'\n                    });\n                 }\n                 });\n                },\n                eventResize: function(event) {\n                 start = $.fullCalendar.formatDate(event.start, \"yyyy-MM-dd HH:mm:ss\");\n                 end = $.fullCalendar.formatDate(event.end, \"yyyy-MM-dd HH:mm:ss\");\n                 datefin  = event.datefin;\n                 done  = event.done;\n                 resource =  event.resourceId;\n                 $.ajax({\n                 url: 'update_events.php',\n                 data: 'title='+ event.title+'&amp;start='+ start +'&amp;end='+ end +'&amp;resourceId='+ resource +'&amp;color='+ event.backgroundColor+'&amp;datefin='+datefin+'&amp;done='+done+'&amp;id='+ event.id ,\n                 type: \"POST\",\n                 success: function(json) {\n                    console.log('update rezise'); \n                   $.pnotify({\n                        title: 'Mise \u00e0 jour r\u00e9ussi',\n                        type: 'success'\n                    });\n                 }\n                 });\n\n                },\n\n\n\n            });\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I have a problem of duplication events. When I create an event always the last event is duplicate. I am required to use location.reload() to avoid that.Someone can help me find a solution. This is my code : $(document).ready(function() { var date = new Date(); var d = date.getDate(); var m = date.getMonth(); var y [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-7932","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7932","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=7932"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7932\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=7932"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=7932"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=7932"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}