Created
December 19, 2012 11:43
-
-
Save vman/4336130 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
| $(document).ready(function(){ | |
| var scriptbase = _spPageContextInfo.webServerRelativeUrl + "_layouts/15/"; | |
| $.getScript(scriptbase + "SP.Runtime.js", | |
| function () { | |
| $.getScript(scriptbase + "SP.js", function(){ | |
| $.getScript(scriptbase + "SP.Taxonomy.js", execOperation); | |
| }); | |
| } | |
| ); | |
| }); | |
| function execOperation(){ | |
| //Current Context | |
| var context = SP.ClientContext.get_current(); | |
| //Current Taxonomy Session | |
| var taxSession = SP.Taxonomy.TaxonomySession.getTaxonomySession(context); | |
| //Term Stores | |
| var termStores = taxSession.get_termStores(); | |
| //Name of the Term Store from which to get the Terms. | |
| var termStore = termStores.getByName("Taxonomy_Dmxzz8tIBzk8wNVKQpJ+xA=="); | |
| //GUID of Term Set from which to get the Terms. | |
| var termSet = termStore.getTermSet("b49f64b3-4722-4336-9a5c-56c326b344d4"); | |
| var terms = termSet.getAllTerms(); | |
| context.load(terms); | |
| context.executeQueryAsync(function(){ | |
| var termEnumerator = terms.getEnumerator(); | |
| var termList = "Terms: \n"; | |
| while(termEnumerator.moveNext()){ | |
| var currentTerm = termEnumerator.get_current(); | |
| termList += currentTerm.get_name() + "\n"; | |
| } | |
| alert(termList); | |
| },function(sender,args){ | |
| console.log(args.get_message()); | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment