Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9162641
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:15:32+00:00 2026-06-17T14:15:32+00:00

I need to be able to implement a filter in my jQuery Mobile project

  • 0

I need to be able to implement a filter in my jQuery Mobile project that would allow me to search a nested list and return all list elements that match the text entered into the filter bar. Basically I need to extend the functionality of the already implemented data-filter function to show results from nested list items as well as visible ones. Is there a way to modify the data-filter behaviour?

My list is set up as follows. I need to return a list with each sitesource and datasource (including child elements) that match the search term.

<ul>
<li class="sitesource">
    <ul>
        <li class="datasource"></li>
        <li class="datasource"></li>
        <li class="datasource"></li>
    </ul>
</li>
<li class="sitesource">
    <ul>
        <li class="sitesource">
            <ul>
                <li class="datasource"></li>
                <li class="datasource"></li>
                <li class="datasource"></li>
            </ul>
        </li>
        <li class="datasource"></li>
    </ul>
</li>
<li class="datasource"></li>
</ul>

I suspect that what I may need to do is (after pageinit) search through the entire html document and return all the matching sitesource and datasource elements in a list – this would probably require a custom built function?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T14:15:33+00:00Added an answer on June 17, 2026 at 2:15 pm

    This is a little verbose, but seems to do what you’re asking:

    function filterSources(myVal){
    var myFilter = myVal;
    
    var dataSources = document.getElementsByClassName("datasource");
    
    //array from nodelist    
    var arr = [];
    for(var i = 0, n; n = dataSources[i]; ++i) arr.push(n);
    
    //filter for text    
    var finalData = arr.filter(function(element){
            return $(element).text().indexOf(myFilter) > -1;
        })
    //compile into string for output
    var newStr = "";
    for(var m in finalData) newStr += finalData[m].textContent + ", ";
    $("#target").html(newStr);
    
    
    }
    
    $(function(){
    
    filterSources
    $("input#search_foo").keyup(function(){
        filterSources($(this).val())
        })
    })
    

    http://jsfiddle.net/klatzkaj/DEmWE/9/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to be able to access a list throughout my Rails project. For
Android Calendar App I need to be able to implement a view similar to
I need to be able to search through multiple 2D arrays and search the
I need to implement nested group membership for generic AD services. Previously, i was
I am building a web site in Django where I would need to implement
I need to be able to implement methods of: Shutdown Restart Logoff Sleep On
I need to be able to implement methods of: Shutdown Restart Logoff Sleep On
Users of the website need to able to store images in their area ,
Need to be able to pull Magento products into an external template. Need to
I need to be able to create an id for a hyperlink. I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.