Created
January 28, 2013 18:39
-
-
Save publickeating/4657940 to your computer and use it in GitHub Desktop.
Allow a collection view to reload if the status of its content changes even if the content's length doesn't change (like with RecordArray's).
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
myStack: SC.StackedView.extend({ | |
// Observes changes to our content. | |
contentDidChange: function () { | |
var previousContent = this.previousContent, | |
this.get('content'); | |
// Clean up observer on previous content | |
if (previousContent) { | |
previousContent.removeObserver('status', this, 'contentStatusDidChange'); | |
} | |
if (content) { | |
content.addObserver('status', this, 'contentStatusDidChange'); | |
} | |
// Reset the previousContent (whether null or not). If this view is destroyed, content should be set to null, clearing out this value. | |
this.previousContent = content; | |
}.observes('content'), | |
// Observes changes in the status of our content. | |
contentStatusDidChange: function () { | |
var status = this.getPath('content.status'); | |
// Reload each time that the content's status goes READY again. | |
if (status & SC.Record.READY) { | |
this.reload(); | |
} | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment