Created
May 20, 2012 18:08
-
-
Save techiferous/2758986 to your computer and use it in GitHub Desktop.
Example of an Ember.js handler
This file contains 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
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