'use strict'; /* global Backbone, _, $, AmCharts */ /* global meetingView */ /* jshint browser: true , devel: true */ (function($) { var MeetingModel = Backbone.Model.extend({ url: '/apiv2/meeting' }); var MeetingView = Backbone.View.extend({ el: '#meetingForm', initialize: function() { }, events: { submit: 'submit' }, submit: function(event) { var self = this; var newObj = {}; var dString; event.preventDefault(); notification.clearAll(); newObj.roomId = parseInt(this.$el.find('select#device')[0].value); dString = [this.$el.find('input#from')[0].value, this.$el.find('input#start')[0].value].join(' '); newObj.start = Date.create(dString); dString = [this.$el.find('input#from')[0].value, this.$el.find('input#end')[0].value].join(' '); newObj.end = Date.create(dString); newObj.occupancy = parseInt(this.$el.find('input#occupancy')[0].value); var meetingRec = new MeetingModel(newObj); meetingRec.save(null, { success: function(model, response) { console.log('success'); notification.notify('success', 'Meeting successfully logged.'); self.$el[0].reset(); }, error: function(model, response) { console.error('error', response); notification.notify('error', 'The meeting couldn\'t be logged.'); } }); } }); var meetingView = new MeetingView(); })(jQuery);