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

jQuery Filter by Site Title

$
0
0

Hi all,

I need to filter results of sub sites by their title. Currently, the filter returns no results. I know it is probably something simple. Here is my code:

<script type="text/javascript" src="https://ajax.aspnetcdn.com/ajax/jquery/jquery-1.9.0.min.js"></script><script type="text/javascript">
    $(function() {
        // Make sure the SharePoint script file 'sp.js' is loaded before your
        // code runs.
        SP.SOD.executeFunc('sp.js', 'SP.ClientContext', sharePointReady);
    });

// Create an instance of the current context.
function sharePointReady() {
    var clientContext = new SP.ClientContext.get_current();
    if (clientContext != undefined && clientContext != null) {
        var web = clientContext.get_web();

        this.webCollection = web.getSubwebsForCurrentUser(null);

        clientContext.load(this.webCollection);
        clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded),Function.createDelegate(this, this.onQueryFailed));
    }
}

function onQuerySucceeded() {
    var webEnumerator = this.webCollection.getEnumerator();
    while (webEnumerator.moveNext()) {
        var web = webEnumerator.get_current();
        $("#SiteList").filter(function(index) {
            if(web.get_title=="Project 1") {
                return true; 
            }
        }).append("<p>" + web.get_title() + web.get_webTemplate() + web.get_url () + "</p>");
    }
}

function onQueryFailed(sender, args) {
    alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}</script><div id="SiteList"><h2>Projects List</h2></div>


Personal Blog: http://thebitsthatbyte.com


Viewing all articles
Browse latest Browse all 25064

Trending Articles



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