Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.
This repository was archived by the owner on Oct 8, 2021. It is now read-only.

Customize the filtering algorithm #1921

Closed
@project707

Description

@project707

The listview filter proceeds to do a character by character filter, which is only useful in very limited number of cases. It doesn't work if all products have reg or tm symbols in them or have long names.

Self-edited rant about lack of low-level documentation here... uneccessary

Activity

toddparker

toddparker commented on Jun 24, 2011

@toddparker
Contributor

This is a good feature request...would you mind adding it to the feature request wiki page?

project707

project707 commented on Jun 24, 2011

@project707
Author

I actually closed it because I felt I had been a bit too harsh about the
documentation thing. We're actually using jquery mobile to build a mobile
site for/at a major company that everybody knows, and in those kinds of
cases as you probably know there is little design/functionality flexibility,
so we have all been experiencing a bit of frustration at the lack of more
detailed documentation. I feel there must be a lot of functionality that
could be hooked into, and styling that can be overriden that we're missing.

I will go ahead and make it into a feature request, and I'll be nice about
it :)

Thanks,
jason

On Fri, Jun 24, 2011 at 12:29 PM, toddparker <
reply@reply.github.com>wrote:

This is a good feature request...would you mind adding it to the feature
request wiki page?

Reply to this email directly or view it on GitHub:
#1921 (comment)

toddparker

toddparker commented on Jun 24, 2011

@toddparker
Contributor

Thanks Jason, I appreciate it! We're a tiny team working on this so features like this aren't as fleshed out right now as we'd all like. If you do figure out a clean way to make this extensible, please submit a patch.

project707

project707 commented on Jun 28, 2011

@project707
Author

So I'm not really familiar with git and submitting patches (been stuck in the svn world), but I have a simple working method to skip any non-alphanumeric characters within the "listview" filter extension that can be enabled by adding data-filter-skipspecial="true" to your listview ul.

It defaults to false:
$.mobile.listview.prototype.options.filterSkipspecial = false;

but if set true does a replace on both input value and "itemtext" with the following:
.replace(/[^a-zA-Z 0-9]+/g,'').replace(/\s+/g,' ');

which only compares like strings containing alphanumeric characters, and without excess whitespace as might be added by removing an ampersand or another character that might stand alone. The character itself can still be typed in without effect, as the compared input string is still filtered.

It might be nice to give developers the option to specify an array of allowed or filtered characters, but I think this would suit our needs for now.

project707

project707 commented on Jul 1, 2011

@project707
Author

I have added this feature to a branch and submitted a pull request.

Sorry for the branch naming convention. I was following https://gist.github.com/726275 instructions and being a gitN00b just followed along exactly.

toddparker

toddparker commented on Jul 6, 2011

@toddparker
Contributor

Pull request here:
https://github.com/project707/jquery-mobile/commit/994f69ce85f40ed54f9ba5ca5d41f198fd4b077a

My thought on this is that instead of creating a special case for this one situation, we'd be better off having a pluggable solution that lets' people use whatever parsing logic they want. I can see the current approach ballooning as people want to add scoping and more complex searching logic.

project707

project707 commented on Aug 19, 2011

@project707
Author

This has been solved by adding a callback allowing one to intercept the filter term:
#2216

Unfortunately another unrelated issue (#2092) that can't easily be solved using this hook was closed instead. Can we keep that one open and close the appropriate one (this)?

toddparker

toddparker commented on Aug 19, 2011

@toddparker
Contributor

Thanks, closing this, will reopen #2092

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @toddparker@project707

        Issue actions

          Customize the filtering algorithm · Issue #1921 · jquery-archive/jquery-mobile