Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

simple filterCallback in the options to delegate complex search to en…

…d users
  • Loading branch information...
commit 6bbf830da8772cdbe2ece9d8138c7c1e3c9dcb0e 1 parent 2d7706a
@johnbender johnbender authored
Showing with 4 additions and 1 deletion.
  1. +4 −1 js/jquery.mobile.listview.filter.js
View
5 js/jquery.mobile.listview.filter.js
@@ -10,6 +10,9 @@
$.mobile.listview.prototype.options.filter = false;
$.mobile.listview.prototype.options.filterPlaceholder = "Filter items...";
$.mobile.listview.prototype.options.filterTheme = "c";
+$.mobile.listview.prototype.options.filterCallback = function( text, searchValue ){
+ return text.toLowerCase().indexOf( searchValue ) === -1;
+};
$( ":jqmData(role='listview')" ).live( "listviewcreate", function() {
@@ -70,7 +73,7 @@ $( ":jqmData(role='listview')" ).live( "listviewcreate", function() {
// New bucket!
childItems = false;
- } else if ( itemtext.toLowerCase().indexOf( val ) === -1 ) {
+ } else if ( listview.options.filterCallback( itemtext, val ) ) {
//mark to be hidden
item.toggleClass( "ui-filter-hidequeue" , true );

3 comments on commit 6bbf830

@kpuputti

Is there a reason why returning a truthy value results in a hidden item and not vice versa?

This is just the opposite to what e.g. Python's builtin 'filter' function or Underscore.js' array filter does.

@johnbender

@kpuputti,

Its a direct port of the original logic and it's certainly up for debate whether that's intuitive. Thanks for commenting.

[UPDATE] I'm going to put this on the list for our discussion this week. Its a small change that'll make this much more usable.

@kpuputti

Thanks, I'll follow for possible updates.

Please sign in to comment.
Something went wrong with that request. Please try again.