Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

SharePoint Online - Get term store terms using javascript in iFrame

$
0
0

I try to create a "Fat footer" in my SharePoint site using an iframe. I load this iframe in the seattle.master. The footer is just a simple .aspx page. So far, so good. In the I frame I want to display some menu items, I load from the term store. I found a few solutions to achieve that but none works for me. I think the problem is I want to load it in the iframe page. Looks like I miss some references or something. This is my current code:

<script src="blabla/scripts/jquery-2.1.4.min.js" type="text/javascript"></script><asp:ScriptManager><Scripts><asp:ScriptReference Path="/_layouts/SP.js" /><asp:ScriptReference Path="/_layouts/SP.Taxonomy.js" /></Scripts></asp:ScriptManager><script type="text/javascript">

$(document).ready(function () {
        //This makes sure all necessary Js files are loaded before you call taxonomy store
        SP.SOD.executeFunc('sp.runtime.js', false, function () {
            SP.SOD.executeFunc('sp.js', 'SP.ClientContext', function () {
                SP.SOD.registerSod('sp.taxonomy.js', SP.Utilities.Utility.getLayoutsPageUrl('sp.taxonomy.js'));//loads sp.taxonomy.js file
                SP.SOD.executeFunc('sp.taxonomy.js', false, GetTermsFromTaxonomyStore);
            });
        });
    });



    //This method uses the Taxonomy client side object calls to get the terms
    function GetTermsFromTaxonomyStore() {

        //Current Context
        var context = SP.ClientContext.get_current();
        //Current Taxonomy Session
        var taxSession = SP.Taxonomy.TaxonomySession.getTaxonomySession(context);
        //Term Store under which to create the term.
        var termStore = taxSession.getDefaultSiteCollectionTermStore();
         //Pass ID of the Meetings Term Set
        var termSet = termStore.getTermSet("termsetid here");
        var terms = termSet.get_terms();
        context.load(terms);
        context.executeQueryAsync(function () {
            var termEnumerator = terms.getEnumerator();
            while (termEnumerator.moveNext()) {
                var currentTerm = termEnumerator.get_current();
                console.log(currentTerm.get_name());
            }
        }, function (sender, args) {
            console.log(args.get_message());
        });
    }</script>
I use the asp.scriptmanager because I read on the net that this might me a solution.

I am even not able to load the differen .js files because I get an "SP is not defined error" on the SP.SOD.executeFunc

Can someone help me out?

Thanks, Mike


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>