Fix for issue #4133 - check all items on each change when custom filter callback applies #4135

Closed
wants to merge 1 commit into
from
Jump to file or symbol
Failed to load files and symbols.
+7 −2
Split
@@ -43,11 +43,16 @@ $( document ).delegate( ":jqmData(role='listview')", "listviewcreate", function(
itemtext = "",
item;
+ // Check if a custom filter callback applies
+ var isCustomFilterCallback = listview.options.filterCallback !=
+ $.mobile.listview.prototype.options.filterCallback;

This comment has been minimized.

Show comment Hide comment
@johnbender

johnbender May 21, 2012

Contributor

I think check only works when the callback is defined using the widget factory method

$( "#mylist" ).listview( 'option', 'filterCallback', yourFilterFunction );

If the user sets the value via the prototype options value eg,

$( document ).bind( "mobileinit", function(){
  $.mobile.listview.prototype.options.filterCallback = function(){
    console.log( "foo" );
  }
});

This check will always return true though it's clearly a custom callback.

@johnbender

johnbender May 21, 2012

Contributor

I think check only works when the callback is defined using the widget factory method

$( "#mylist" ).listview( 'option', 'filterCallback', yourFilterFunction );

If the user sets the value via the prototype options value eg,

$( document ).bind( "mobileinit", function(){
  $.mobile.listview.prototype.options.filterCallback = function(){
    console.log( "foo" );
  }
});

This check will always return true though it's clearly a custom callback.

+
// Change val as lastval for next execution
$this.jqmData( "lastval" , val );
- if ( val.length < lastval.length || val.indexOf(lastval) !== 0 ) {
+
+ if ( isCustomFilterCallback || ( val.length < lastval.length || val.indexOf(lastval) !== 0 ) ) {
- // Removed chars or pasted something totally different, check all items
+ // Custom filter callback applies, removed chars or pasted something totally different; check all items
listItems = list.children();
} else {