Hi all,
Trying to follow the 'HTML5 Event Calendar (Open-Source)' tutorial to load some events from an SQL database table. Set up my project same-as example yet can't get Events to load. Using debug.writeline has helped me to determine that the 'Events' function in BackendController isn't being run.
Backend controller is setup like so:
###########################
public class BackendController : Controller
{
CalendarEntities db = new CalendarEntities();
public class JsonEvent
{
public string id { get; set; }
public string text { get; set; }
public string start { get; set; }
public string end { get; set; }
}
public ActionResult Events(DateTime? start, DateTime? end)
{
Debug.WriteLine("Events called");
// SQL: SELECT * FROM [event] WHERE NOT (([end] <= @start) OR ([start] >= @end))
var events = from ev in db.CalendarShift.AsEnumerable() where !(ev.end <= start || ev.start >= end) select ev;
var result = events
.Select(e => new JsonEvent()
{
start = e.start.ToString("s"),
end = e.end.ToString("s"),
text = e.name,
id = e.id.ToString()
})
.ToList();
return new JsonResult { Data = result };
}
}
###########################
Relevant part of script that should be calling this function is:
###########################
function loadEvents() {
var start = dp.visibleStart();
var end = dp.visibleEnd();
$.post("backend/events",
{
start: start.toString(),
end: end.toString()
},
function (data) {
console.log(data);
dp.events.list = data;
dp.update();
});
}
###########################
loadEvents(); is called right before the above code.
I'm not getting any java/jquery errors and as far as I can tell all scripts are being loaded correctly. I can't find any differences between the demo project and mine, excepting that mine is getting the events from the database table (called 'CalendarShifts').
I'm not getting an "Events called" output in the console when debugging (though when adding the Debug.Writeline into the demo project, I am).
Is anyone able to assist?
Many thanks.