jqMobi-Plugins icon indicating copy to clipboard operation
jqMobi-Plugins copied to clipboard

Support for Tables in filterlist

Open algernon83 opened this issue 12 years ago • 5 comments

Hi there -- I made a small modification to filterlist to support tables. Before making a pull request, I wanted to see if this is outside your intended scope?

algernon83 avatar Apr 11 '12 14:04 algernon83

Push the change to your fork and I'll be glad to check it out.

imaffett avatar Apr 11 '12 14:04 imaffett

Thanks. Done. I'm used to Subversion, so forgive me if I've messed up part of the process.

I also included code to let you specify a class to apply to the input. (I wanted to get the default styling for jq.ui -- love those rounded corners and shadows.)

Note: I changed a line in refresh() to always take the child element as the target, never the grandchild -- otherwise only the first cell of each row would be filtered. It didn't affect lists in my testing, but maybe I missed an important test case. I changed this: eachEle.target = elem.childNodes[0].tagName !== undefined ? elem.childNodes[0] : elem to this: eachEle.target = elem;

algernon83 avatar Apr 11 '12 15:04 algernon83

Ok - the reason I added that was for this case.

<li><a href="foo">Bar</a></li>

When searching, I want it to search the contents of the anchor tag and not the

  • - this is to resemble how it works in jQueryMobile. That's why we need to look at elem.childNodes[0] so we will look at the child if one exists.
  • imaffett avatar Apr 11 '12 15:04 imaffett

    I was thinking - if you add an option (filterChildren) that defaults to true, then it should work in both cases. You'd set it to false for tables or others.

    imaffett avatar Apr 12 '12 16:04 imaffett

    In testing filterlist from your repository, I found that child elements actually are searched, to any depth -- is this not by design? This is the mark-up for the <li> I used for that test case:

    <li>
    <div>
    content nested in div
    <div>two levels deep
    <div>three levels deep
    <div>four levels deep
    <div>five levels deep</div></div></div>
    </div>
    </div>
    </li>
    

    I was able to search successfully for "five levels deep". I believe this is because the code looks at the innerHTML of the matched node. Perhaps we want it to go through all children of the matched nodes, compile only the values of text nodes (i.e. don't search through any HTML markup), and filter on that? We wouldn't even need a separate flag; we would hit all the text of the elements being searched.

    PS -- My e-mail is [email protected] if you want to take this offline at any time, to clear up any confusion or miscommunication, and get only the resolution/official spec into the official channels.

    algernon83 avatar Apr 13 '12 13:04 algernon83