TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
parthasarathy B
NA
927
107.4k
How to get library url in the below piece of code
Sep 19 2018 8:14 PM
Hi all,
I am working on the task which retrieves all the subsites from the site collection and its lists and libraries names and its url to bind in the div.I got all worked but i didn't get url of the document library which should be bind as a URL in the list name so that we can navigate to the libraries by clicking it.I posted my code below any help would be helpful. Thanks in advance.
<script language=
"javascript"
type=
"text/javascript"
>
$(document).ready(
function
() {
SP.SOD.executeFunc(
'sp.js'
,
'SP.ClientContext'
,getAllWebs);
});
function
getAllWebs(success,error)
{
var
ctx = SP.ClientContext.get_current();
var
web = ctx.get_site().get_rootWeb();
var
level = 0;
jQuery(
"#tonydashboard"
).empty();
var
html4 =
"<div class='tab'>"
;
var
getAllWebsInner =
function
(web,success,error)
{
var
ctx = web.get_context();
var
webs = web.getSubwebsForCurrentUser(
null
);
//var webs = web.get_webs();
ctx.load(webs,
'Include(Title,Webs,ServerRelativeUrl,Lists)'
);
ctx.executeQueryAsync(
function
(){
for
(
var
i = 0; i < webs.get_count();i++){
var
web = webs.getItemAtIndex(i);
var
webtitle = web.get_title();
var
weburl = web.get_serverRelativeUrl();
jQuery(
"#tonydashboard"
).after(
"<div id='"
+webtitle+
"' alt='"
+webtitle+
"' style='display:none'></div>"
);
this
.listColl= web.get_lists();
var
listEnumerator =
this
.listColl.getEnumerator();
while
(listEnumerator.moveNext()) {
debugger
;
var
oList = listEnumerator.get_current();
listInfo =
'Title: '
+ oList.get_title() +
' BaseType: '
+
oList.get_baseType() +
'\n'
;
//var listFullUrl = window.location.origin + oList.get_defaultViewUrl();
var
siteTitle=web.get_title();
var
listTitle=oList.get_title();
$(
"[id='"
+siteTitle+
"']"
).append(
"<div onclick='window.open('newurl.html','mywindow');' style='cursor: pointer;'>"
+listTitle+
"</div>"
);
console.log(listInfo);
}
//var html3="<button class='tablinks' onclick='openCity(this)'>"+webtitle+"</button>";
var
html3=
"<input id='btnSearch' class='tablinks' type='button' onclick='openCity(this)' name='"
+webtitle+
"' value='"
+webtitle+
"'>"
;
jQuery(
"#tonydashboard"
).append(html3);
if
(web.get_webs().get_count() > 0) {
getAllWebsInner(web,success,error);
}
}
},
error);
};
getAllWebsInner(web,success,error);
jQuery(
"#tonydashboard"
).append(
'</div>'
);
}
</script>
<div id=
"tonycontent"
>
<!-- Dashboard -->
<div id=
"tonydashboard"
class
=
"tonycontenttable"
>
</div>
</div>
Reply
Answers (
1
)
How to get all the subsites and its lists using jsom
Need help in SP2016 migration.