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
72 lines (47 loc) • 1.68 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.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('category/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;
});