Skip to content

Instantly share code, notes, and snippets.

@lukemelia
Created December 16, 2011 15:55
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 lukemelia/1486569 to your computer and use it in GitHub Desktop.
Save lukemelia/1486569 to your computer and use it in GitHub Desktop.
App.ProjectSelectView = Ember.CollectionView.extend({
selected: null,
itemViewClass: Ember.View.extend({
attributeBindings:['selected'],
valueBinding: 'content.selected'
}),
valueChanged: function(){
this.$().val( this.get('selected') );
}.observes('selected'),
didInsertElement: function(){
var self = this;
this.$().change(function(){
var val = $('select option:selected').val();
console.log(val)
self.set('value', val);
});
}
});
// Project
App.Project = Ember.Object.extend({
_id: '',
title: '',
info: '',
testimonial: '',
type: '',
created_at: '',
updated_at: '',
photos: [],
available_types: [
{value: 'landscape', name: 'Landscape', selected: false},
{value: 'remodel', name: 'Remodel', selected: true},
{value: 'new', name: 'New', selected: false}
],
formattedDate: function () {
return (new Date(this.get("created_at"))).toDateString();
}.property("created_at").cacheable(),
formattedType: function () {
return this.get("type").charAt(0).toUpperCase() + this.get("type").slice(1);
}.property("type")
});
App.currentProject = App.Project.create();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment