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

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 7 additions & 2 deletions js/jquery.mobile.listview.filter.js
Expand Up @@ -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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {

Expand Down