diff --git a/js/jQuery.mobile.listview.js b/js/jQuery.mobile.listview.js
index b8bfa16d..de2ea38c 100644
--- a/js/jQuery.mobile.listview.js
+++ b/js/jQuery.mobile.listview.js
@@ -17,39 +17,9 @@ $.widget( "mobile.listview", $.mobile.widget, {
},
_create: function() {
- var parentID = this.element.closest( ".ui-page" ).attr( "id" ),
- o = this.options;
+ var o = this.options;
- //if it's a nested list, chunk it into ui-page items, recurse through them and call listview on each individual ul
- $( this.element.find( "ul,ol" ).get().reverse() ).each(function( i ) {
- var list = $( this ),
- id = parentID + "&" + jQuery.mobile.subPageUrlKey + "=listview-" + i,
- parent = list.parent(),
- title = parent.contents()[ 0 ].nodeValue,
- theme = list.data( "theme" ) || o.theme,
- countTheme = list.data( "count-theme" ) || o.countTheme;
-
- list.wrap( "
" )
- .parent()
- .before( "" )
- .parent()
- .attr({
- id: id,
- "data-theme": theme,
- "data-count-theme": countTheme
- })
- .appendTo( "body" )
- .fixHeaderFooter()
- .find( ".ui-header a.ui-back" )
- .buttonMarkup()
- .click(function() {
- history.go(-1);
- return false;
- });
-
- parent.html( "" + title + "" );
- }).listview();
+ this._createSubPages();
//create listview markup
this.element
@@ -146,23 +116,8 @@ $.widget( "mobile.listview", $.mobile.widget, {
.end()
.find( "p,ul,dl" )
.addClass( "ui-li-desc" );
-
- // JS fallback for auto-numbering for OL elements
- if( !$.support.cssPseudoElement && this.element.is('ol') ){
- var counter = 1;
- this.element.find('li').each(function(){
- if( $(this).is('.ui-li-grouping') ){
- //reset counter when a grouping heading is encountered
- counter = 1;
- }
- else {
- $(this)
- .find('.ui-link-inherit:first')
- .addClass('ui-li-jsnumbering')
- .prepend('' + counter++ + '. ');
- }
- });
- }
+
+ this._numberItems();
//tapping the whole LI triggers ajaxClick on the first link
this.element.find( "li:has(a)" ).live( "tap", function(event) {
@@ -171,6 +126,60 @@ $.widget( "mobile.listview", $.mobile.widget, {
return false;
}
});
+ },
+
+ _createSubPages: function() {
+ var parentId = this.element.closest( ".ui-page" ).attr( "id" ),
+ o = this.options;
+ $( this.element.find( "ul,ol" ).get().reverse() ).each(function( i ) {
+ var list = $( this ),
+ id = parentId + "&" + $.mobile.subPageUrlKey + "=listview-" + i,
+ parent = list.parent(),
+ title = parent.contents()[ 0 ].nodeValue,
+ theme = list.data( "theme" ) || o.theme,
+ countTheme = list.data( "count-theme" ) || o.countTheme;
+
+ list.wrap( "" )
+ .parent()
+ .before( "" )
+ .parent()
+ .attr({
+ id: id,
+ "data-theme": theme,
+ "data-count-theme": countTheme
+ })
+ .appendTo( "body" )
+ .fixHeaderFooter()
+ .find( ".ui-header a.ui-back" )
+ .buttonMarkup()
+ .click(function() {
+ history.go(-1);
+ return false;
+ });
+
+ parent.html( "" + title + "" );
+ }).listview();
+ },
+
+ // JS fallback for auto-numbering for OL elements
+ _numberItems: function() {
+ if ( $.support.cssPseudoElement || !this.element.is( "ol" ) ) {
+ return;
+ }
+ var counter = 1;
+ this.element.find( ".ui-li-dec" ).remove();
+ this.element.find( "li:visible" ).each(function() {
+ if( $( this ).is( ".ui-li-grouping" ) ) {
+ //reset counter when a grouping heading is encountered
+ counter = 1;
+ } else {
+ $( this )
+ .find( ".ui-link-inherit:first" )
+ .addClass( "ui-li-jsnumbering" )
+ .prepend( "" + (counter++) + ". " );
+ }
+ });
}
});
diff --git a/js/jquery.mobile.listview.filter.js b/js/jquery.mobile.listview.filter.js
index 028fcf3f..bb49660e 100644
--- a/js/jquery.mobile.listview.filter.js
+++ b/js/jquery.mobile.listview.filter.js
@@ -3,26 +3,31 @@
$.mobile.listview.prototype.options.filter = false;
$( ":mobile-listview" ).live( "listviewcreate", function() {
- var list = $( this );
- if ( !list.data( "listview" ).options.filter ) {
+ var list = $( this ),
+ listview = list.data( "listview" );
+ if ( !listview.options.filter ) {
return;
}
- var wrapper = $( "