Skip to content

Instantly share code, notes, and snippets.

@pbse
Last active April 26, 2016 03:16
Show Gist options
  • Select an option

  • Save pbse/d7c2e8510673d2cd6446 to your computer and use it in GitHub Desktop.

Select an option

Save pbse/d7c2e8510673d2cd6446 to your computer and use it in GitHub Desktop.
Fullcalendar in Backbone
$(function() {
data = [{
"start": "2015-06-20 15:00:00",
"end": "2015-06-20 16:00:00",
"title": "Java"
}, {
"start": "2015-06-20 15:00:00",
"end": "2015-06-20 16:00:00",
"title": "Java"
}, {
"start": "2015-06-20 15:00:00",
"end": "2015-06-20 16:00:00",
"title": "Java"
}];
Service = Backbone.Model.extend({
defaults: {
title: null,
start: null,
end: null
}
});
ServiceCollection = Backbone.Collection.extend({
model: Service,
});
App = Backbone.View.extend({
initialize: function() {
this.model = new Service();
},
render: function() {
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,basicWeek,basicDay',
ignoreTimezone: false
},
selectable: true,
selectHelper: true,
editable: true,
ignoreTimezone: false,
});
$('#calendar').fullCalendar("addEventSource", this.collection.toJSON());
}
});
var myCollection = new ServiceCollection(data);
new App({
collection: myCollection
}).render();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment