To update a navigation note in SharePoint quick lanuch, we can do by JSOM. In below example we are updating the red box node.
collChildNavNode =null,
getNavigationNode = function(web, listData)
{
var clientContext = CORO.megaMenucontext;
// Get the Quick Launch navigation node collection.
quickLaunchNodeCollection = web.get_navigation().get_quickLaunch();
clientContext.load(quickLaunchNodeCollection);
clientContext.executeQueryAsync(getNavigationNodeSuccess,onQueryFailed);
},
getNavigationNodeSuccess = function (sender, args) {
var url = currentProjectObject .Title.replace(/[^a-z0-9\s]/gi, '').replace(/[_\s]/g, '');
var clientContext = CORO.megaMenucontext;
collChildNavNode = quickLaunchNodeCollection.get_item(0);
clientContext.load(collChildNavNode);
clientContext.executeQueryAsync(createNavNode ,onQueryFailed);
},
createNavNode = function()
{
var url = currentProjectObject .Title.replace(/[^a-z0-9\s]/gi, '').replace(/[_\s]/g, '');
var clientContext = CORO.megaMenucontext;
collChildNavNode.set_title('Home');
collChildNavNode.set_url("/sites/dk/sites/projects/" +url);
collChildNavNode.update();
clientContext.executeQueryAsync(createNavNodeSuccess, onQueryFailed);
},
createNavNodeSuccess = function()
{
console.log("Created navigation node");
},
getNavigationNode = function(web, listData)
{
var clientContext = CORO.megaMenucontext;
// Get the Quick Launch navigation node collection.
quickLaunchNodeCollection = web.get_navigation().get_quickLaunch();
clientContext.load(quickLaunchNodeCollection);
clientContext.executeQueryAsync(getNavigationNodeSuccess,onQueryFailed);
},
getNavigationNodeSuccess = function (sender, args) {
var url = currentProjectObject .Title.replace(/[^a-z0-9\s]/gi, '').replace(/[_\s]/g, '');
var clientContext = CORO.megaMenucontext;
collChildNavNode = quickLaunchNodeCollection.get_item(0);
clientContext.load(collChildNavNode);
clientContext.executeQueryAsync(createNavNode ,onQueryFailed);
},
createNavNode = function()
{
var url = currentProjectObject .Title.replace(/[^a-z0-9\s]/gi, '').replace(/[_\s]/g, '');
var clientContext = CORO.megaMenucontext;
collChildNavNode.set_title('Home');
collChildNavNode.set_url("/sites/dk/sites/projects/" +url);
collChildNavNode.update();
clientContext.executeQueryAsync(createNavNodeSuccess, onQueryFailed);
},
createNavNodeSuccess = function()
{
console.log("Created navigation node");
},
No comments:
Post a Comment