| Issue 904: | Event sources duplciate | |
| 1 person starred this issue and may be notified of changes. | Back to list |
Using your calendar i use several evenSources.
Every time I change a view event sources get removed and added.
Adding to the complication I catch eventClicks and try to determine whether 'event.name' is the current event if not then 'changeview' to another event.
If the view is the same view then another exact same source is added on top of the existing source and duplicates identical sources.
Some code.
viewDisplay: function(view) {
if (view.name == 'month') {
if ( '<%=brsEnabled %>' == 'True' )
{ $('#calendar').fullCalendar( 'addEventSource', '/diaryFeed.aspx?style=brsBasic' );
$('#calendar').fullCalendar( 'removeEventSource', '/diaryFeed.aspx?style=brs' ); }
}
if (view.name == 'basicDay') {
if ( '<%=brsEnabled %>' == 'True' ) { $('#calendar').fullCalendar( 'removeEventSource', '/diaryFeed.aspx?style=brsBasic' ); $('#calendar').fullCalendar( 'addEventSource', '/diaryFeed.aspx?style=brs' ); }
}
},
//EVENT CLICK
eventClick: function( event, jsEvent, view )
{
var view = $('#calendar').fullCalendar('getView');
if (view.name == 'month')
{
$('#calendar').fullCalendar( 'gotoDate', event.start );
****THIS IS CAUSING ME AN ISSUE-- EVERYTIME THE SAME VIEW IS CALLED IT
$('#calendar').fullCalendar('changeView', 'basicDay');
}
if (view.name == 'basicDay')
{
--------
Now it might be silly for you but I think it is a bit strange to be able to duplicate the exact same source?
Anyway I know how to bypass the problem.
Before calling the view I should check if I am not calling the same view...
I realised that while typing this.. but for your consideration
Thanks
Apr 13, 2011
#1
p.stud...@gmail.com
Apr 13, 2011
I found a work around for my case but its not brilliant
set global var lastView;
.
.
.
viewDisplay: function(view) {
if (lastView == undefined) { lastView = $('#calendar').fullCalendar('getView'); }
if (view.name != lastView.name)
{
if (view.name == 'month') {
if ( '<%=brsEnabled %>' == 'True' ) { $('#calendar').fullCalendar( 'addEventSource', '/diaryFeed.aspx?style=brsBasic' ); $('#calendar').fullCalendar( 'removeEventSource', '/diaryFeed.aspx?style=brs' ); }
lastView = $('#calendar').fullCalendar('getView');
}
if (view.name == 'basicDay') {
if ( '<%=brsEnabled %>' == 'True' ) { $('#calendar').fullCalendar( 'removeEventSource', '/diaryFeed.aspx?style=brsBasic' ); $('#calendar').fullCalendar( 'addEventSource', '/diaryFeed.aspx?style=brs' ); }
lastView = $('#calendar').fullCalendar('getView');
}
}
so i check if the same view is called. if not then it updates the global var fires my functions and set the view to the global var.
PS
This also solves my problem with the viewDisplay firing on load. So now it knows the defualt view is showing and wont duplicate eventSources...
I really thing you need to split the date and view events..
May 8, 2011
im not exactly sure what you are trying to achieve, but a sure way to prevent event source duplicates is to always remove the same event source before you add it.
Status:
Done
|
|
| ► Sign in to add a comment |