Skip to content

Instantly share code, notes, and snippets.

@techiferous
Created May 20, 2012 18:08
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 techiferous/2758986 to your computer and use it in GitHub Desktop.
Save techiferous/2758986 to your computer and use it in GitHub Desktop.
Example of an Ember.js handler
App.handlers.employees = Ember.Object.create({
add: function() {
App.viewables.newEmployee.reset();
App.viewables.employeeFormPane.set('adding', true);
},
cancel: function() {
App.viewables.employeeFormPane.set('adding', false);
},
create: function() {
var employee = App.viewables.newEmployee,
title = employee.get('title'),
firstName = employee.get('firstName'),
lastName = employee.get('lastName'),
kind = employee.get('kind');
if ($('form#add_employee').valid()) {
App.storables.employees.create({
title: title,
firstName: firstName,
lastName, lastName,
kind: kind.value
});
employee.reset();
App.viewables.employeeFormPane.set('adding', false);
}
},
openDetails: function(event) {
var viewable = event.context.content;
viewable.set('detailsShowing', true);
},
closeDetails: function(event) {
var viewable = event.context.content;
viewable.set('detailsShowing', false);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment