Created
November 16, 2010 23:06
-
-
Save charlesjolley/702705 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
BlogMe.postController = SC.ObjectController.create({ | |
contentBinding: 'BlogMe.postsController.selection' | |
}); |
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
// 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' | |
}); |
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
BlogMe.postsController = SC.ArrayController.create({ | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment