javascript - Jquery Mobile List Custom Filter Search -



javascript - Jquery Mobile List Custom Filter Search -

i want alter default filter jquery mobile lists, that:

<ul data-role="listview" data-filter="true" data-filter-placeholder="search fruits..." data-inset="true"> <li><a href="#">apple</a></li> <li><a href="#">banana</a></li> <li><a href="#">cherry</a></li> <li><a href="#">cranberry</a></li> <li><a href="#">grape</a></li> <li><a href="#">orange</a></li> </ul>

i found page, jquery mobile api documentation, show how do.

jquery mobile documentation custom filter example

this code. search line number, , not text:

$( document ).on( "mobileinit", function() { $.mobile.filterable.prototype.options.filtercallback = function( index, searchvalue ) { var idx; if ( searchvalue ) { searchvalue = searchvalue.split( "," ); searchvalue = $.map( searchvalue, function( element ) { var ar = element.split( "-" ); homecoming ar.length === 1 ? parseint( element ) : [ [ parseint( ar[ 0 ] ), parseint( ar[ 1 ] ) ] ]; }); ( idx = 0 ; idx < searchvalue.length ; idx++ ) { if ( ( $.type( searchvalue[ idx ] ) === "number" && index === searchvalue[ idx ] ) || ( $.type( searchvalue[ idx ] ) === "array" && index >= searchvalue[ idx ][ 0 ] && index <= searchvalue[ idx ][ 1 ] ) ) { homecoming false; } } } homecoming !!searchvalue; }; });

but, unfortunately, couldn't create work.

here did. same code documentation above:

my example

i hope helps me find solution ^^

and question.

how work, if utilize javascripts @ end of body?

thanks attention.

javascript jquery jquery-mobile

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -