Plato on Github
Report Home
ampersand/template/shared/client/pages/person-edit.js
Maintainability
78.11
Lines of code
41
Difficulty
9.80
Estimated Errors
0.29
Function weight
By Complexity
By SLOC
/*global alert*/ var app = require('ampersand-app'); var PageView = require('./base'); var templates = require('../templates'); var PersonForm = require('../forms/person'); module.exports = PageView.extend({ pageTitle: 'edit person', template: templates.pages.personEdit, initialize: function (spec) { var self = this; app.people.getOrFetch(spec.id, {all: true}, function (err, model) { if (err) alert('couldnt find a model with id: ' + spec.id); self.model = model; }); }, subviews: { form: { // this is the css selector that will be the `el` in the // prepareView function. container: 'form', // this says we'll wait for `this.model` to be truthy waitFor: 'model', prepareView: function (el) { var model = this.model; return new PersonForm({ el: el, model: this.model, submitCallback: function (data) { model.save(data, { wait: true, success: function () { app.navigate('/collections'); } }); } }); } } } });