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

SharePoint 2013 set “Structural Navigation: Display only the navigation items below the current site” JavaScript

$
0
0

As the title says, I currently have JavaScript that sets the navigation, however it currently sets it too "Structural Navigation: Display the current site, the navigation items below the current site, and the current site's siblings" I cant seem to get it to set too "Structural Navigation: Display only the navigation items below the current site"

We are using a SharePoint online environment and we have built the javascript into the page layout.

This is the code I currently have:

$(document).ready(function(){

    var scriptBase = _spPageContextInfo.webAbsoluteUrl + "/_layouts/15/";

    $.getScript(scriptBase + "sp.runtime.js",function(){

        $.getScript(scriptBase + "sp.js",function(){

            $.getScript(scriptBase + "sp.publishing.js", modifyNavigation);

        });
    });

function modifyNavigation(){


    var context = SP.ClientContext.get_current();


    var currentWeb = context.get_web();


    var webNavSettings = new SP.Publishing.Navigation.WebNavigationSettings(context, currentWeb);


    var navigation = webNavSettings.get_currentNavigation();

    navigation.set_source(1);

    webNavSettings.update();

    context.executeQueryAsync(function(){

        console.log("Navigation set");

    },function(sender,args){

        alert(args.get_message());

    });


}   

With this code I end up with the following result: Navigation

Is it possible to have the code set the bottom radio button?

Any help is appreciated.



Viewing all articles
Browse latest Browse all 7589

Trending Articles



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