Created
October 22, 2011 11:37
-
-
Save pencilcheck/1305897 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function() { | |
// TODO: need to test education out before moving on to other sections | |
// A education item | |
window.myordo.EducationItem = Spine.Controller.sub({ | |
events: { | |
'click .close': 'close', | |
"click .addConcentration": "addConcentration" | |
}, | |
init: function() { | |
this.item.bind('update', this.proxy(this.render)); | |
this.item.bind('destroy', this.proxy(this.remove)); | |
}, | |
render: function(item) { | |
if (item) this.item = item; | |
return this.html(this.template(this.item)); | |
}, | |
template: function(items) { | |
return $('#sectionTemplate').tmpl(items); | |
}, | |
remove: function() { | |
this.el.remove(); | |
}, | |
close: function() { | |
this.item.destroy(); | |
}, | |
addConcentration: function(e) { | |
// Adding another input field for major or minor input field in the form | |
}, | |
}); | |
// Managing Education items | |
window.myordo.Educations = Spine.Controller.sub({ | |
init: function() { | |
window.myordo.Education.bind('create', this.proxy(this.addOne)); | |
window.myordo.Education.bind('refresh', this.proxy(this.addAll)); | |
}, | |
addOne: function(item) { | |
var edu = new window.myordo.EducationItem({item: item}); | |
this.prepend(edu.render()); | |
}, | |
addAll: function() { | |
window.myordo.Education.each(this.proxy(this.addOne)); | |
}, | |
}); | |
window.myordo.EducationForm = Spine.Controller.sub({ | |
events: { | |
'click .addInput': 'addInput', | |
'submit form#education-form': 'create', | |
}, | |
init: function() { | |
}, | |
addInput: function() { | |
// Create a new input for major/minor | |
//this.$('') | |
}, | |
create: function(e) { | |
e.preventDefault(); | |
// Follow the rest here http://spinejs.com/docs/forms | |
//window.myordo.Education.create({}); | |
}, | |
}); | |
window.myordo.VResume = Spine.Controller.sub({ | |
init: function() { | |
var edu, exp, ski, lan; | |
var edu_form, exp_form, ski_form, lan_form; | |
edu = new window.myordo.Educations({el: $('#education')}); | |
edu_form = new window.myordo.EducationForm({el: $('form#education-form')}); | |
window.myordo.Resume.bind('refresh', this.proxy(this.populateFields)); | |
window.myordo.Resume.fetch(); | |
}, | |
// Update the view | |
populateFields: function(resumes) { | |
var resume; | |
if (resumes && resumes.length > 0) { | |
resume = resumes[0]; | |
} | |
else { | |
// If resumes is empty then create one | |
// Below should send a POST request | |
resume = window.myordo.Resume.create({ | |
first_name: '', | |
last_name: '', | |
}); | |
} | |
}, | |
}); | |
// Init the app to get the resume_id and populate the resume | |
var app = new window.myordo.VResume(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment