Created
November 17, 2008 21:57
-
-
Save ttdonovan/25923 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
| _currSelGuid: null, // keep track of current selection guid | |
| // myController.addProbe(selection) | |
| refreshRecordWhenSelected: function () { | |
| // cannot observe selection for changes because of SC.SelectionSupport#updateSelectionAfterContentChange in sproutcore/mixins/selection_support.js | |
| // if (!this.didChangeFor('refreshRecordWhenSelected', 'selection')) { return ; } | |
| var sel = this.get('selection'), | |
| record = null ; | |
| if (sel.length == 1) { | |
| record = sel.first() ; | |
| } else { | |
| this.set('_currSelGuid', null) ; // empty current selection | |
| return ; // empty selection or invalid number of selections | |
| } | |
| // check if record is different from current selection | |
| if (record.guid != this.get('_currSelGuid')) { | |
| if (!record.newRecord) { record.refresh(); } | |
| this.set('_currSelGuid', record.guid) ; // set current selection for selection observation | |
| } | |
| }.observes('selection') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment