diff --git a/docs/lists/lists-autodivide.html b/docs/lists/lists-autodivide.html
new file mode 100644
index 00000000000..c1e2e0c97e6
--- /dev/null
+++ b/docs/lists/lists-autodivide.html
@@ -0,0 +1,98 @@
+
+
+
+
+
+ jQuery Mobile Docs - List Dividers
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
More in this section
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/js/jquery.mobile.listview.js b/js/jquery.mobile.listview.js
index ee94e12eab1..9a4e0e5f0f0 100644
--- a/js/jquery.mobile.listview.js
+++ b/js/jquery.mobile.listview.js
@@ -21,7 +21,8 @@ $.widget( "mobile.listview", $.mobile.widget, {
splitIcon: "arrow-r",
splitTheme: "b",
inset: false,
- initSelector: ":jqmData(role='listview')"
+ initSelector: ":jqmData(role='listview')",
+ autodivide: false
},
_create: function() {
@@ -117,9 +118,11 @@ $.widget( "mobile.listview", $.mobile.widget, {
listsplittheme = $list.jqmData( "splittheme" ),
listspliticon = $list.jqmData( "spliticon" ),
li = $list.children( "li" ),
+ autodivideLastLetter = "NONE",
counter = $.support.cssPseudoElement || !$.nodeName( $list[ 0 ], "ol" ) ? 0 : 1,
item, itemClass, itemTheme,
- a, last, splittheme, countParent, icon;
+ a, last, splittheme, countParent, icon,
+ firstChar, autodividerElem;
if ( counter ) {
$list.find( ".ui-li-dec" ).remove();
@@ -195,6 +198,27 @@ $.widget( "mobile.listview", $.mobile.widget, {
}
}
+ if(self.options.autodivide && (item.text().length > 0)) {
+ // get the first character of the text
+ firstChar = item.text()[0];
+ if(firstChar != autodivideLastLetter) {
+ autodivideLastLetter = firstChar;
+
+ // Create a new element for the autodivider
+ autodividerElem = $("");
+ autodividerElem.addClass ("ui-li ui-li-divider ui-btn ui-bar-" + dividertheme);
+ autodividerElem.attr("data-role", "list-divider");
+ autodividerElem.attr("role", "heading");
+ autodividerElem.text(firstChar);
+ item.before(autodividerElem);
+
+ if( counter ) {
+ counter = 1;
+ }
+ }
+ }
+
+
if ( counter && itemClass.indexOf( "ui-li-divider" ) < 0 ) {
countParent = item.is( ".ui-li-static:first" ) ? item : item.find( ".ui-link-inherit" );