Reputation: 1
I am using this calendar for Titanium SDK. What I need to do is retrieve a list of dates from a server, and if a date on the calendar has an event, add an image to the tile to represent that. I can retrieve the day, but the problem is the day is not specific to the date. For example if the date retrieved was 08/12/2012, the day is equal to 8. When I go to set the image in the code like so:
calendar.setImage(eventDay, 'path/to/image');
it sets the 8th day of every month and not just the the the 8th of December.
Here is the setImage function from the calendar controller:
exports.setImage = function(day,image, options) {
var _ref3;
if (options == null) {
options = {};
}
if (moment.isMoment()) {
day = day.date();
}
tile = (_ref3 = $.calendar) != null ? _ref3["" + day] : void 0;
if ((tile != null ? tile.date : void 0) != null) {
tile.remove(tile.children[0]);
_.extend(tile, {
_isEntry: true
}, options);
return tile.add(Ti.UI.createImageView({
image: image,
width: TILE_WIDTH,
height: TILE_WIDTH,
touchEnabled: true
}));
}
};
I tried changing the code to accept the month and year and then added the extra variables to the _ref3 variable, but that didn't work at all.
Upvotes: -2
Views: 152
Reputation: 2018
Use the inbuilt library with the Alloy i.e
require('alloy/moment');
Moment.js is a useful library for handling time specific display.
Upvotes: 0
Reputation: 241525
It looks to me like this control just works with one month at a time.
Take a look at their sample code. See that it removes the calendar and re-creates it in the doPrevMonth
and doNextMonth
functions.
Since you are setting the image of a particular cell, referenced by the day number. You will need to clear this, or re-set it any time you change months.
In other words, your question does not make sense, because this particular control has no ability to work with more than one month. The title doesn't match what you are asking either.
If you are already doing this every time you draw the calendar, then just check that the input date matches the month you are showing.
Upvotes: 0