diff --git a/docs/lists/index.html b/docs/lists/index.html
index 83125b49aca..2f46b84760f 100755
--- a/docs/lists/index.html
+++ b/docs/lists/index.html
@@ -33,7 +33,8 @@
Lists
Thumbnails
Icons
Content formatting
- Search filter bar
+ Search filter bar
+ Search filter bar with dividers
Inset styled lists
List performance test
Theming lists
diff --git a/docs/lists/lists-search-with-dividers.html b/docs/lists/lists-search-with-dividers.html
new file mode 100644
index 00000000000..24d48f406a0
--- /dev/null
+++ b/docs/lists/lists-search-with-dividers.html
@@ -0,0 +1,64 @@
+
+
+
+
+ jQuery Mobile Docs - Lists
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/js/jquery.mobile.listview.filter.js b/js/jquery.mobile.listview.filter.js
index f72aa47bb5a..3a56fdfa8d4 100644
--- a/js/jquery.mobile.listview.filter.js
+++ b/js/jquery.mobile.listview.filter.js
@@ -22,12 +22,30 @@ $( "[data-role='listview']" ).live( "listviewcreate", function() {
"data-type": "search"
})
.bind( "keyup change", function() {
- var val = this.value.toLowerCase();;
- list.children().show();
+ var val = this.value.toLowerCase(),
+ list_items = list.children();
+ list_items.show();
if ( val ) {
- list.children().filter(function() {
- return $( this ).text().toLowerCase().indexOf( val ) === -1;
- }).hide();
+ // This handles hiding regular rows without the text we search for
+ // and any list dividers without regular rows shown under it
+ var any_in_the_bucket = false,
+ item;
+
+ for (var i = list_items.length; i >= 0; i--) {
+ item = $(list_items[i]);
+ if (item.is("li[data-role=list-divider]")) {
+ if (!any_in_the_bucket) {
+ item.hide();
+ }
+ // New bucket!
+ any_in_the_bucket = false;
+ } else if (item.text().toLowerCase().indexOf( val ) === -1) {
+ item.hide();
+ } else {
+ // There's a shown item in the bucket
+ any_in_the_bucket = true;
+ }
+ }
}
//listview._numberItems();
diff --git a/tests/unit/listview/index.html b/tests/unit/listview/index.html
index 13873069440..10f52942aaf 100644
--- a/tests/unit/listview/index.html
+++ b/tests/unit/listview/index.html
@@ -171,5 +171,24 @@ Split List View
+
+
+
+
Split List View
+
+
+
+ - a
+ - a is for aquaman
+ - b
+ - b is for batman
+ - c
+ - c is for catwoman
+ - d
+ - d is for darkwing
+
+
+
+