Skip to content

Instantly share code, notes, and snippets.

@joubertnel
Created October 15, 2011 15:13
Show Gist options
  • Save joubertnel/1289689 to your computer and use it in GitHub Desktop.
Save joubertnel/1289689 to your computer and use it in GitHub Desktop.
Dynamic state transition from sibling states in a SproutCore state chart
gotoStateFromFirstSiblingCurrentState: function(destinationState, commonParentState, defaultSourceState) {
var sourceState = this.get('currentStates').find(function(s) {
var isSibling = s.getPath('parentState.stateName') === commonParentState;
return isSibling;
});
sourceState = sourceState || defaultSourceState;
this.gotoState(destinationState, sourceState);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment