Permalink
Browse files

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

…d users
  • Loading branch information...
johnbender committed Aug 4, 2011
1 parent 2d7706a commit 6bbf830da8772cdbe2ece9d8138c7c1e3c9dcb0e
Showing with 4 additions and 1 deletion.
  1. +4 −1 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

This comment has been minimized.

Show comment
Hide comment
@kpuputti

kpuputti Aug 15, 2011

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.

kpuputti replied Aug 15, 2011

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

This comment has been minimized.

Show comment
Hide comment
@johnbender

johnbender Aug 15, 2011

Contributor

@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.

Contributor

johnbender replied Aug 15, 2011

@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

This comment has been minimized.

Show comment
Hide comment
@kpuputti

kpuputti Aug 16, 2011

Thanks, I'll follow for possible updates.

kpuputti replied Aug 16, 2011

Thanks, I'll follow for possible updates.

Please sign in to comment.