Several planner bugs have been fixed in v0.2. These changes are in svn as well as in the zip archive. The changes also appear in the HEAD (for the new version).
Summary of changes:
1) Corrected event date check for initial load. Previously, events that fell out just outside of the current month did not show up on the initial load. (ex 2/29 when viewing March). Changed date comparison to look at the scal instance dateRange array instead of current month.
2) Multiple dates style bug. Styles for different events on the same date not set properly, especially when one date is part of a range. Fixed.
removeEventsByDate bug
Thanks for reporting this!
Check out the latest version and report back the results!
http://code.google.com/p/scaljs/source/browse/trunk/javascripts/scalplan...
ReplacePlanner function still not working with new version
I downloaded the new zip file with the latest changes. I'm still having trouble in the call to setPlannerValue in my replacePlanner function.
First, here is my function again:
replacePlanner: function(newPlanner){
for (var d in this.planner) {
var dt = new Date( d );
this.removeEventsByDate(dt);
}
for ( var planId in newPlanner ) {
var plan = newPlanner[planId];
var planDate;
if(Object.isString(plan.period)) {
planDate = new Date(plan.period);
}
else {
planDate = plan.period;
}
if ( planDate != null )
this.setPlannerValue( planDate.getFullYear(), planDate.getMonth() + 1, planDate.getDate(), plan.label, plan.cls );
}
It correctly removes all the current events and it correctly calls setPlannerValue. However, inside setPlannerValue it is not able to find any element in this line:
var el = this.cells[cellIndex].select('.dayboxvalue')[0];
That line just leaves "el" as undefined in javascript (using Firebug to debug). Whereas before the latest code the "this" special variable was pointing to the Window instead of the scal object, it does now correctly point to the scal object while I'm inside setPlannerValue, but it is just unable to find any element object.
Any ideas? Is there a better way to do what I'm trying to do which is to remove all the elements and just put an entirely new planner in place but without refreshing the entire calendar?
David
Here is the fix
I found the problem. removeEventsByDate is too aggressive in the default mode where you just supply a date and not a second argument saying which event on that date to remove. Here is line 100 from the current version:
this.cells[cellIndex].select('.dayboxvalue').invoke('remove');
The problem with that is that it removes the entire dayboxvalue div element, yet the setPlannerValue function depends on that div still existing so it can put new p elements inside it. Rather than remove the entire dayboxvalue div if no arguments are given to removeEventsByDate we should just loop through all the p elements in that div and remove them. So I removed line 100 and added this and it works fine now:
for(var index = this.cells[cellIndex].select('.dayboxvalue p').length - 1; index >= 0; index--)
this.cells[cellIndex].select('.dayboxvalue p')[index].remove();
Hope that helps,
David
Post new comment