Skip to content

Instantly share code, notes, and snippets.

@jasonm
Created September 19, 2011 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasonm/dddd26ba632cdac725ba to your computer and use it in GitHub Desktop.
Save jasonm/dddd26ba632cdac725ba to your computer and use it in GitHub Desktop.
Iora.Views.Patients.FamilyHistory = Iora.Views.CompositeView.extend({
tagName: 'div',
className: 'inner-wrapper',
id: 'patient-family-history',
events: {
'click a#edit-family-history': 'renderForm',
'click button#save-family-history': 'save',
'click button#cancel-family-history': 'render'
},
render: function() {
if (this.model.has('family_history')) {
$(this.el).html(JST['patients/family_history']( { patient: this.model }) );
this.$('p').markdown();
} else {
$(this.el).html(JST['patients/family_history_unassigned']({ patient: this.model }));
}
return this;
},
renderForm: function() {
$(this.el).html(JST['patients/family_history_form']({ patient: this.model }));
this.$('textarea#family_history').focus();
},
save: function() {
var self = this;
var form = this.$('form');
this.model.saveFromForm(form, {
success: function() {
self.render();
}
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment