piyushkothari3 / jmonthcalendar

Automatically exported from code.google.com/p/jmonthcalendar
Other
0 stars 0 forks source link

for loop binding problem breaks 'Show More' #40

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Add more than 4 events spanning multiple days, covering the entire current 
month. (In this particular case, there were events spanning around 10 months 
involved.)
2. Add an extra single-day event on a date somewhere in the middle of the 
calendar.
3. Click 'Show More' on the date box for the day on which the extra single-day 
event was added

What is the expected output? What do you see instead?
- It is expected that the 'onShowMoreClick' callback should receive a list of 
events including the long-running events as well as the extra single-day event. 
However, this is not the case - only the long-running events are present in the 
list given to the callback.

Version: jMonthCalendar 1.3.2-beta2

---

This problem arises due to the way the 'Show More' link callbacks are set up in 
_drawEventsOnCalendar(): the for loop iterating from istart to iend sets the 
boxIndex to the iteration index. This introduces a late binding problem such 
that 'onShowMoreClick' always refers to the last box index. This can be fixed 
by replacing the for loop with a closure, such as with the use of jquery 
.each(). The attached patch provides such a fix.

Original issue reported on code.google.com by eleu...@gmail.com on 22 Jun 2010 at 9:55

Attachments: