Last active
December 28, 2015 22:08
-
-
Save edchat/7568957 to your computer and use it in GitHub Desktop.
Function to get the Parent View from a View Target
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
getParentFromViewTarget: function (viewTarget) { | |
// summary: | |
// A convenience function to get the Parent View for a View Target | |
// | |
// viewTarget: | |
// The view target, like "ParentView1,SubViewA,ChildViewX" | |
// | |
// Calls would look like this: | |
// | |
// var parentViewOfChildViewX = this.app.getParentFromViewTarget("ParentView1,SubViewA,ChildViewX"); | |
// | |
var p = this; | |
var parts = viewTarget.split(","); | |
if (p && parts.length > 1) { | |
for (var i = 0; i < parts.length - 1; i++) { | |
var toId = parts[i]; | |
var v = p.children[p.id + "_" + toId]; | |
if (v) { | |
p = v; | |
} else { | |
console.log("Parent view has not been created yet for " + viewTarget); | |
return null; | |
} | |
} | |
} | |
console.log("in getParentFromViewTarget for viewTarget [" + viewTarget + "] parent [" + p.id + "]"); | |
return p; | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment