full calendar events appearing twice












1















After creating an event the style remains. But sometimes the events appear to be duplicated. The jquery code and screen shots are attached for better understanding.



enter image description here



this is how the events look after loading from backend



this is my jquery functions



select: function (start, end) {
var title = "Available";
var eventData;
if (title) {
eventData = {
title: title,
start: start,
end: end
};
$('#calendar').fullCalendar('renderEvent', eventData, true); // stick? = true

createEvent(eventData);

window.setTimeout(function () {
location.reload()
}, 300);

$.notifyBar({
cssClass: "WARNING",
html: "Created Successfully."
});
}
$('#calendar').fullCalendar('unselect');

},

eventSources: [{
events: function (start, end, timezone, callback) {
var employeeId = $("#employee-Id").val();
$.ajax({
url: '../' + employeeId + '/events',
dataType: 'json',
success: function (response) {
var events = $.parseJSON(response.data);
callback(events);
}
});
}
}],
eventRender: function (event, element) {
//delete event on double click..Tanvir
element.unbind("dblclick").one().bind('dblclick', function (e) {

$("#startTime").html(moment(event.start).format(' DD/MM/YYYY, HH:mm'));
$("#endTime").html(moment(event.end).format('DD/MM/YYYY, HH:mm'));

$("#eventContent").dialog({modal: true, title: event.title, width: 100});

$('.delete-event').unbind("click").click(function (e) {
e.preventDefault();
$('#calendar').fullCalendar('removeEvents', event._id);
deleteEvent(event.id);
$("#eventContent").hide();

});

$('.discard-delete').bind('click', function () {
$("#eventContent").hide();
});
});

function createEvent(eventData) {
$(document).ready(function () {
$(function () {
$.ajax(
{
beforeSend: function (xhr) {
xhr.setRequestHeader("Accept", "application/json");
},
url: '../availability/create',
contentType: "application/json",
type: 'GET',
traditional: true,
data: {
eventsJson:JSON.stringify(eventData),
id: $("#employee-Id").val()
},
dataType: "json",
success: function (response) {
},
error: function (xhr) {

}

});
});
});
}


this is all about i can provide.Please feel free to ask if you need more info










share|improve this question

























  • It's unclear to me what the issue is. As far as I can see, what you've got there in the first screenshot is simply two events occurring on the same date and time. How you created them, I don't know - either your event feed from the server, or your "select" callback might have done it. Did you go through some particular process which causes them to appear like that? If so, please clarify. Perhaps there's an issue server-side where things are being duplicated.

    – ADyson
    Nov 22 '18 at 9:31













  • BTW 1) why are you calling location.reload() after you create an event? It seems a bit unnecessary to refresh the whole page, just because you added an event into the calendar. What does that achieve?

    – ADyson
    Nov 22 '18 at 9:32






  • 1





    and 2) .bind() and .unbind() were superseded by better functions .on() and .off() all the way back in jQuery 1.7 - you should not be using those functions in new code. They are now officially deprecated too, so you can expect them to stop working completely in a future upgrade. See the documentation for details

    – ADyson
    Nov 22 '18 at 9:33













  • i used location.reload() for some special purpose such as validationg if there is already exisitng availability then just reload the page and not creating that availability.

    – TanvirChowdhury
    Nov 22 '18 at 10:12











  • i used bind and unbind to prevent double click problem. and i m using jquery 3

    – TanvirChowdhury
    Nov 22 '18 at 10:13
















1















After creating an event the style remains. But sometimes the events appear to be duplicated. The jquery code and screen shots are attached for better understanding.



enter image description here



this is how the events look after loading from backend



this is my jquery functions



select: function (start, end) {
var title = "Available";
var eventData;
if (title) {
eventData = {
title: title,
start: start,
end: end
};
$('#calendar').fullCalendar('renderEvent', eventData, true); // stick? = true

createEvent(eventData);

window.setTimeout(function () {
location.reload()
}, 300);

$.notifyBar({
cssClass: "WARNING",
html: "Created Successfully."
});
}
$('#calendar').fullCalendar('unselect');

},

eventSources: [{
events: function (start, end, timezone, callback) {
var employeeId = $("#employee-Id").val();
$.ajax({
url: '../' + employeeId + '/events',
dataType: 'json',
success: function (response) {
var events = $.parseJSON(response.data);
callback(events);
}
});
}
}],
eventRender: function (event, element) {
//delete event on double click..Tanvir
element.unbind("dblclick").one().bind('dblclick', function (e) {

$("#startTime").html(moment(event.start).format(' DD/MM/YYYY, HH:mm'));
$("#endTime").html(moment(event.end).format('DD/MM/YYYY, HH:mm'));

$("#eventContent").dialog({modal: true, title: event.title, width: 100});

$('.delete-event').unbind("click").click(function (e) {
e.preventDefault();
$('#calendar').fullCalendar('removeEvents', event._id);
deleteEvent(event.id);
$("#eventContent").hide();

});

$('.discard-delete').bind('click', function () {
$("#eventContent").hide();
});
});

function createEvent(eventData) {
$(document).ready(function () {
$(function () {
$.ajax(
{
beforeSend: function (xhr) {
xhr.setRequestHeader("Accept", "application/json");
},
url: '../availability/create',
contentType: "application/json",
type: 'GET',
traditional: true,
data: {
eventsJson:JSON.stringify(eventData),
id: $("#employee-Id").val()
},
dataType: "json",
success: function (response) {
},
error: function (xhr) {

}

});
});
});
}


this is all about i can provide.Please feel free to ask if you need more info










share|improve this question

























  • It's unclear to me what the issue is. As far as I can see, what you've got there in the first screenshot is simply two events occurring on the same date and time. How you created them, I don't know - either your event feed from the server, or your "select" callback might have done it. Did you go through some particular process which causes them to appear like that? If so, please clarify. Perhaps there's an issue server-side where things are being duplicated.

    – ADyson
    Nov 22 '18 at 9:31













  • BTW 1) why are you calling location.reload() after you create an event? It seems a bit unnecessary to refresh the whole page, just because you added an event into the calendar. What does that achieve?

    – ADyson
    Nov 22 '18 at 9:32






  • 1





    and 2) .bind() and .unbind() were superseded by better functions .on() and .off() all the way back in jQuery 1.7 - you should not be using those functions in new code. They are now officially deprecated too, so you can expect them to stop working completely in a future upgrade. See the documentation for details

    – ADyson
    Nov 22 '18 at 9:33













  • i used location.reload() for some special purpose such as validationg if there is already exisitng availability then just reload the page and not creating that availability.

    – TanvirChowdhury
    Nov 22 '18 at 10:12











  • i used bind and unbind to prevent double click problem. and i m using jquery 3

    – TanvirChowdhury
    Nov 22 '18 at 10:13














1












1








1








After creating an event the style remains. But sometimes the events appear to be duplicated. The jquery code and screen shots are attached for better understanding.



enter image description here



this is how the events look after loading from backend



this is my jquery functions



select: function (start, end) {
var title = "Available";
var eventData;
if (title) {
eventData = {
title: title,
start: start,
end: end
};
$('#calendar').fullCalendar('renderEvent', eventData, true); // stick? = true

createEvent(eventData);

window.setTimeout(function () {
location.reload()
}, 300);

$.notifyBar({
cssClass: "WARNING",
html: "Created Successfully."
});
}
$('#calendar').fullCalendar('unselect');

},

eventSources: [{
events: function (start, end, timezone, callback) {
var employeeId = $("#employee-Id").val();
$.ajax({
url: '../' + employeeId + '/events',
dataType: 'json',
success: function (response) {
var events = $.parseJSON(response.data);
callback(events);
}
});
}
}],
eventRender: function (event, element) {
//delete event on double click..Tanvir
element.unbind("dblclick").one().bind('dblclick', function (e) {

$("#startTime").html(moment(event.start).format(' DD/MM/YYYY, HH:mm'));
$("#endTime").html(moment(event.end).format('DD/MM/YYYY, HH:mm'));

$("#eventContent").dialog({modal: true, title: event.title, width: 100});

$('.delete-event').unbind("click").click(function (e) {
e.preventDefault();
$('#calendar').fullCalendar('removeEvents', event._id);
deleteEvent(event.id);
$("#eventContent").hide();

});

$('.discard-delete').bind('click', function () {
$("#eventContent").hide();
});
});

function createEvent(eventData) {
$(document).ready(function () {
$(function () {
$.ajax(
{
beforeSend: function (xhr) {
xhr.setRequestHeader("Accept", "application/json");
},
url: '../availability/create',
contentType: "application/json",
type: 'GET',
traditional: true,
data: {
eventsJson:JSON.stringify(eventData),
id: $("#employee-Id").val()
},
dataType: "json",
success: function (response) {
},
error: function (xhr) {

}

});
});
});
}


this is all about i can provide.Please feel free to ask if you need more info










share|improve this question
















After creating an event the style remains. But sometimes the events appear to be duplicated. The jquery code and screen shots are attached for better understanding.



enter image description here



this is how the events look after loading from backend



this is my jquery functions



select: function (start, end) {
var title = "Available";
var eventData;
if (title) {
eventData = {
title: title,
start: start,
end: end
};
$('#calendar').fullCalendar('renderEvent', eventData, true); // stick? = true

createEvent(eventData);

window.setTimeout(function () {
location.reload()
}, 300);

$.notifyBar({
cssClass: "WARNING",
html: "Created Successfully."
});
}
$('#calendar').fullCalendar('unselect');

},

eventSources: [{
events: function (start, end, timezone, callback) {
var employeeId = $("#employee-Id").val();
$.ajax({
url: '../' + employeeId + '/events',
dataType: 'json',
success: function (response) {
var events = $.parseJSON(response.data);
callback(events);
}
});
}
}],
eventRender: function (event, element) {
//delete event on double click..Tanvir
element.unbind("dblclick").one().bind('dblclick', function (e) {

$("#startTime").html(moment(event.start).format(' DD/MM/YYYY, HH:mm'));
$("#endTime").html(moment(event.end).format('DD/MM/YYYY, HH:mm'));

$("#eventContent").dialog({modal: true, title: event.title, width: 100});

$('.delete-event').unbind("click").click(function (e) {
e.preventDefault();
$('#calendar').fullCalendar('removeEvents', event._id);
deleteEvent(event.id);
$("#eventContent").hide();

});

$('.discard-delete').bind('click', function () {
$("#eventContent").hide();
});
});

function createEvent(eventData) {
$(document).ready(function () {
$(function () {
$.ajax(
{
beforeSend: function (xhr) {
xhr.setRequestHeader("Accept", "application/json");
},
url: '../availability/create',
contentType: "application/json",
type: 'GET',
traditional: true,
data: {
eventsJson:JSON.stringify(eventData),
id: $("#employee-Id").val()
},
dataType: "json",
success: function (response) {
},
error: function (xhr) {

}

});
});
});
}


this is all about i can provide.Please feel free to ask if you need more info







javascript jquery ajax fullcalendar






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 22 '18 at 10:34







TanvirChowdhury

















asked Nov 22 '18 at 8:48









TanvirChowdhuryTanvirChowdhury

552412




552412













  • It's unclear to me what the issue is. As far as I can see, what you've got there in the first screenshot is simply two events occurring on the same date and time. How you created them, I don't know - either your event feed from the server, or your "select" callback might have done it. Did you go through some particular process which causes them to appear like that? If so, please clarify. Perhaps there's an issue server-side where things are being duplicated.

    – ADyson
    Nov 22 '18 at 9:31













  • BTW 1) why are you calling location.reload() after you create an event? It seems a bit unnecessary to refresh the whole page, just because you added an event into the calendar. What does that achieve?

    – ADyson
    Nov 22 '18 at 9:32






  • 1





    and 2) .bind() and .unbind() were superseded by better functions .on() and .off() all the way back in jQuery 1.7 - you should not be using those functions in new code. They are now officially deprecated too, so you can expect them to stop working completely in a future upgrade. See the documentation for details

    – ADyson
    Nov 22 '18 at 9:33













  • i used location.reload() for some special purpose such as validationg if there is already exisitng availability then just reload the page and not creating that availability.

    – TanvirChowdhury
    Nov 22 '18 at 10:12











  • i used bind and unbind to prevent double click problem. and i m using jquery 3

    – TanvirChowdhury
    Nov 22 '18 at 10:13



















  • It's unclear to me what the issue is. As far as I can see, what you've got there in the first screenshot is simply two events occurring on the same date and time. How you created them, I don't know - either your event feed from the server, or your "select" callback might have done it. Did you go through some particular process which causes them to appear like that? If so, please clarify. Perhaps there's an issue server-side where things are being duplicated.

    – ADyson
    Nov 22 '18 at 9:31













  • BTW 1) why are you calling location.reload() after you create an event? It seems a bit unnecessary to refresh the whole page, just because you added an event into the calendar. What does that achieve?

    – ADyson
    Nov 22 '18 at 9:32






  • 1





    and 2) .bind() and .unbind() were superseded by better functions .on() and .off() all the way back in jQuery 1.7 - you should not be using those functions in new code. They are now officially deprecated too, so you can expect them to stop working completely in a future upgrade. See the documentation for details

    – ADyson
    Nov 22 '18 at 9:33













  • i used location.reload() for some special purpose such as validationg if there is already exisitng availability then just reload the page and not creating that availability.

    – TanvirChowdhury
    Nov 22 '18 at 10:12











  • i used bind and unbind to prevent double click problem. and i m using jquery 3

    – TanvirChowdhury
    Nov 22 '18 at 10:13

















It's unclear to me what the issue is. As far as I can see, what you've got there in the first screenshot is simply two events occurring on the same date and time. How you created them, I don't know - either your event feed from the server, or your "select" callback might have done it. Did you go through some particular process which causes them to appear like that? If so, please clarify. Perhaps there's an issue server-side where things are being duplicated.

– ADyson
Nov 22 '18 at 9:31







It's unclear to me what the issue is. As far as I can see, what you've got there in the first screenshot is simply two events occurring on the same date and time. How you created them, I don't know - either your event feed from the server, or your "select" callback might have done it. Did you go through some particular process which causes them to appear like that? If so, please clarify. Perhaps there's an issue server-side where things are being duplicated.

– ADyson
Nov 22 '18 at 9:31















BTW 1) why are you calling location.reload() after you create an event? It seems a bit unnecessary to refresh the whole page, just because you added an event into the calendar. What does that achieve?

– ADyson
Nov 22 '18 at 9:32





BTW 1) why are you calling location.reload() after you create an event? It seems a bit unnecessary to refresh the whole page, just because you added an event into the calendar. What does that achieve?

– ADyson
Nov 22 '18 at 9:32




1




1





and 2) .bind() and .unbind() were superseded by better functions .on() and .off() all the way back in jQuery 1.7 - you should not be using those functions in new code. They are now officially deprecated too, so you can expect them to stop working completely in a future upgrade. See the documentation for details

– ADyson
Nov 22 '18 at 9:33







and 2) .bind() and .unbind() were superseded by better functions .on() and .off() all the way back in jQuery 1.7 - you should not be using those functions in new code. They are now officially deprecated too, so you can expect them to stop working completely in a future upgrade. See the documentation for details

– ADyson
Nov 22 '18 at 9:33















i used location.reload() for some special purpose such as validationg if there is already exisitng availability then just reload the page and not creating that availability.

– TanvirChowdhury
Nov 22 '18 at 10:12





i used location.reload() for some special purpose such as validationg if there is already exisitng availability then just reload the page and not creating that availability.

– TanvirChowdhury
Nov 22 '18 at 10:12













i used bind and unbind to prevent double click problem. and i m using jquery 3

– TanvirChowdhury
Nov 22 '18 at 10:13





i used bind and unbind to prevent double click problem. and i m using jquery 3

– TanvirChowdhury
Nov 22 '18 at 10:13












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53426976%2ffull-calendar-events-appearing-twice%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53426976%2ffull-calendar-events-appearing-twice%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

404 Error Contact Form 7 ajax form submitting

How to know if a Active Directory user can login interactively

TypeError: fit_transform() missing 1 required positional argument: 'X'