onEventSelect not working correctly on IOS

I’m trying to retrieve the data from a selected event. It works fine in preview and on android, but on ios this is what happens:

  1. click event one, displays correct jobid
  2. click event two, displays jobid for event one
  3. click event two, displays correct jobid

I’m building a cordova mobile app with monaca/onsen ui.

$(function () {
			var now = new Date(),
				calendar = $('#mobiscroll').mobiscroll().eventcalendar({
					display: 'inline',
					view: {
						calendar: { type: 'week' },
						eventList: { type: 'day', scrollable: true }
					},

				onPageLoading: function (event, inst) {

					var year = event.firstDay.getFullYear(),
						month = event.firstDay.getMonth();

					mobiscroll.util.getJson('http://x.x.x.x:8888/mobile/service?ac=getAllJobsMobi&cpaID=34&year=' + year + '&month=' + (month + 1), function (data) {
						var events = [];

						for (var i = 0; i < data.length; i++) {
							events.push({
								start: data[i].start,
								end: data[i].end,
								d: data[i].d,
								text: data[i].text,
								color: data[i].color,
								jobid: data[i].jobid
							});
						}

						inst.setEvents(events);
					}, 'json');
				},
				onEventSelect: function (event, inst) {
					alert(event.event.jobid);
				}
			}).mobiscroll('getInst');

This isn’t really an ideal solution, but I found that calling refresh after I deal with the selection allows it to work correctly with the next event tap.

onEventSelect: function (event, inst) {
						alert(event.event.jobid);
						$('#mobiscroll').mobiscroll('refresh');	
					}

Hi Justin,

This seems to be an issue with the behavior of alert on iOS. Since the onEventSelect on touch devices is fired on touchend, calling an alert here will stop the execution on some events.
I could simply workaround this by placing the alert inside a setTimeout:

onEventSelect: function (event, inst) {
  setTimeout(function () {
    alert(event.event.jobid);
  });
}
1 Like