Permalink
Browse files

hint to fix #2490

  • Loading branch information...
1 parent 265ffb6 commit a9bb050f32eafd572da1660918c08b5edbc1577e @hpbuniat committed Sep 23, 2011
Showing with 13 additions and 7 deletions.
  1. +13 −7 js/jquery.mobile.degradeInputs.js
View
20 js/jquery.mobile.degradeInputs.js 100644 → 100755
@@ -28,24 +28,30 @@ $.mobile.page.prototype.options.keepNative = ":jqmData(role='none'), :jqmData(ro
//auto self-init widgets
$( document ).bind( "pagecreate enhance", function( e ){
-
+
var page = $( e.target ).data( "page" ),
o = page.options;
-
+
// degrade inputs to avoid poorly implemented native functionality
$( e.target ).find( "input" ).not( o.keepNative ).each(function() {
var $this = $( this ),
type = this.getAttribute( "type" ),
optType = o.degradeInputs[ type ] || "text";
if ( o.degradeInputs[ type ] ) {
- $this.replaceWith(
- $( "<div>" ).html( $this.clone() ).html()
- .replace( /\s+type=["']?\w+['"]?/, " type=\"" + optType + "\" data-" + $.mobile.ns + "type=\"" + type + "\" " )
- );
+ if (this.type !== type) {
+ this.type = optType;
+ $this.data($.mobile.ns + "type", type);
+ }
+ else {
+ $this.replaceWith(
+ $( "<div>" ).html( $this.clone() ).html()
+ .replace( /\s+type=["']?\w+['"]?/, " type=\"" + optType + "\" data-" + $.mobile.ns + "type=\"" + type + "\" " )
+ );
+ }
}
});
-
+
});
})( jQuery );

0 comments on commit a9bb050

Please sign in to comment.