grunt-doctrine
Version:
Grunt plugin to convert doctrine xml annotations into backbone models and collections. Useful in conjunction with doctrine apigility. Includes option to scaffold an entire BBB application
82 lines (55 loc) • 2.07 kB
JavaScript
define(function(require, exports, module) {
"use strict";
var app = require("app");
var logger = require("lib/console");
var SelectBox = require("lib/selectbox");
var OptionsGrid = require("lib/optionsgrid");
var Layout = Backbone.View.extend({
/************ Backbone.LayoutManager *****************/
manage: true,
template: require("ldsh!./template"),
beforeRender: function() {
logger.debug('beforeRender');
},
afterRender: function() {
logger.debug('afterRender');
this.setView('.selectbox-client', new SelectBox({
el: this.$el.find('.selectbox-client'),
collection: app.dataModel.client
}));
this.setView('.selectbox-invoiceStatus', new SelectBox({
el: this.$el.find('.selectbox-invoiceStatus'),
collection: app.dataModel.invoiceStatus
}));
this.modelBinder.bind(this.model, this.$('.form'));
},
serialize: function() {
return {
model: this.model
};
},
/************ Backbone.View *****************/
submitForm: function() {
logger.debug('submitForm');
this.listenToOnce(this.model, 'sync', this.onSaveSuccess, this);
this.model.save();
},
onSaveSuccess: function() {
logger.debug('onSaveSuccess', this.model);
app.router.navigate('invoice/list', true);
},
initialize: function() {
logger.debug('initialize');
this.modelBinder = new Backbone.ModelBinder();
logger.debug('modelBinder', this.modelBinder);
this.listenTo(this.model, 'change', this.onModelChanged, this);
},
onModelChanged: function() {
logger.debug('onModelChanged', this.model);
},
events: {
"click .submitForm": "submitForm"
}
});
module.exports = Layout;
});