Skip to content
This repository
Browse code

Issue #3081: Range inputs on dialogs don't degrade

The degradeInputs plugin bails early for pages that do not have
data-role="page". This behavior prevented range inputs (for slider widgets)
from degrading properly when used in dialogs.

Updated degradeInputs unit tests to check dialogs, too.
  • Loading branch information...
commit a8c04855b4c18399a453a84cb4dd802e3a66cdce 1 parent a9d9ca3
Ethan Romba authored November 21, 2011
2  js/jquery.mobile.degradeInputs.js
@@ -24,7 +24,7 @@ $.mobile.page.prototype.options.degradeInputs = {
24 24
 //auto self-init widgets
25 25
 $( document ).bind( "pagecreate create", function( e ){
26 26
 
27  
-	var page = $(e.target).closest(':jqmData(role="page")').data("page"), options;
  27
+	var page = $(e.target).closest(':jqmData(role="page"),:jqmData(role="dialog")').data("page"), options;
28 28
 
29 29
 	if( !page ) {
30 30
 		return;
14  tests/unit/degradeInputs/degradeInputs.js
@@ -14,15 +14,23 @@
14 14
         var degradeInputs = $.mobile.page.prototype.options.degradeInputs;
15 15
     
16 16
         expect( degradeInputs.length );
17  
-    
  17
+ 
  18
+        // Initialize dialog page
  19
+        $.mobile.changePage($('#dialog'));
  20
+        $.mobile.changePage($('#page'));
  21
+
18 22
         $.each(degradeInputs, function( oldType, newType ) {
19 23
             if (newType === false) {
20 24
                 newType = oldType;
21 25
             }
22 26
             
23  
-            $('#test-container').html('<input type="' + oldType + '" />').trigger("create");
  27
+            $('#page-test-container').html('<input type="' + oldType + '" />').trigger("create");
24 28
             
25  
-            same($('#test-container input').attr("type"), newType);
  29
+            same($('#page-test-container input').attr("type"), newType);
  30
+
  31
+            $('#dialog-test-container').html('<input type="' + oldType + '" />').trigger("create");
  32
+
  33
+            same($('#dialog-test-container input').attr("type"), newType);
26 34
         });
27 35
     });
28 36
 	
11  tests/unit/degradeInputs/index.html
@@ -25,11 +25,18 @@ <h2 id="qunit-userAgent"></h2>
25 25
 <ol id="qunit-tests">
26 26
 </ol>
27 27
 
28  
-<div id="foo"  data-nstest-role="page">
  28
+<div id="page" data-nstest-role="page">
29 29
 	
30 30
 	<input id="not-to-be-degraded" type="range" data-nstest-role="nojs" />
31 31
 	
32  
-	<div id="test-container">
  32
+	<div id="page-test-container">
  33
+	</div>
  34
+	
  35
+</div>
  36
+
  37
+<div id="dialog" data-nstest-role="dialog">
  38
+	
  39
+	<div id="dialog-test-container">
33 40
 	</div>
34 41
 	
35 42
 </div>

0 notes on commit a8c0485

Please sign in to comment.
Something went wrong with that request. Please try again.