Skip to content

Instantly share code, notes, and snippets.

@charlesjolley
Created November 16, 2010 23:06
Show Gist options
  • Save charlesjolley/702705 to your computer and use it in GitHub Desktop.
Save charlesjolley/702705 to your computer and use it in GitHub Desktop.
BlogMe.postController = SC.ObjectController.create({
contentBinding: 'BlogMe.postsController.selection'
});
// OPTION 1 for post list -- traditional
BlogMe.PostListView = SC.View.extend(SC.ContentDisplay, {
// the posts you will display
content: null,
// binds to selection on array controller for mouseDown
selection: null,
// return YES to indicate that you want to handle this mouse event. you
// could also show a highlight state or return NO if you want to be disabled...
mouseDown: function() {
return YES;
},
mouseUp: function(evt) {
var post = this._findPostForEvt(evt); // assume you impl this somehow
this.set('selection', post);
},
// this will cause it to re-render anytime the content object or the array content
// changes
contentDisplayProperties: '[]',
render: function() {
}
});
/// HERE IS HOW YOU SET THIS UP IN YOUR main_page.js:
postList: BlogMe.PostListView.design({
contentBinding: 'BlogMe.postsController.arrangedObjects',
selectionBinding: 'BlogMe.postsController.selection'
});
BlogMe.postsController = SC.ArrayController.create({
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment