The component has a "next" and "previous" which lets you move between weeks. So I had the following code:
/** * Calendar functions */ function addEventHandlersToCalendarComponent() { $('#previousWeekButton').click(function() { $("#calendarViewInMs").val($('#calendarViewInMs').val() - MILLISECONDS_IN_A_WEEK); refreshCalendar(); return false; }); $('#nextWeekButton').click(function() { $("#calendarViewInMs").val($('#calendarViewInMs').val() + MILLISECONDS_IN_A_WEEK); refreshCalendar(); return false; }); $('#calendarDateGoButton').click(function() { refreshCalendar(); return false; }); }The previous week worked perfectly, but clicking the next week broke with the server saying it couldn't parse the number.
Hmm.
After thinking about, and seeing the actual value being sent to the server, it was obvious: "-" operators convert both operands into a number, the "+" operator however, does no such goodness, it simple does a string concatenation. The solution was simple, to use the parseInt to coerce the result of the "val()" method into an actual int.
No comments:
Post a Comment