I need to get a subweb with a particular title using JSOM. So far, the only way I can see to do this would be to use code similar to the following:
function getStuff() {
var oWebsite = clientContext.get_web();
collWebs = oWebsite.get_webs();
clientContext.load(collWebs, 'Include(Title, Url)');
clientContext.executeQueryAsync(
Function.createDelegate(this, this.onQuerySucceeded),
Function.createDelegate(this, this.onQueryFailed)
);
}
function onQuerySucceeded() {
var webInfo = '';
var websEnumerator = collWebs.getEnumerator();
while (websEnumerator.moveNext()) {
var oWeb = websEnumerator.get_current();
webInfo += 'Title: ' + oWeb.get_title() + ' Url: ' +
oWeb.get_url() + '\n';
}
}
where I'm forced to go through the entire collection of webs using the enumerator. Is there any way to get a particular web, similar to the way you can do the following on a List Collection?
get_lists().getByTitle("MyCustomList");

0 commentaires:
Enregistrer un commentaire