Skip to content
This repository
Browse code

Merge pull request #2289 from SamuelKC/selectDomCacheFix2

check the domCache option before rebinding the page remove on select menu
  • Loading branch information...
commit 866b1b0db4070294556e40a92caa1670a246f551 2 parents 3d14498 + e8f78da
John Bender authored
8  js/jquery.mobile.forms.select.custom.js
@@ -248,9 +248,11 @@
248 248
 					// rebind the page remove that was unbound in the open function
249 249
 					// to allow for the parent page removal from actions other than the use
250 250
 					// of a dialog sized custom select
251  
-					self.thisPage.bind( "pagehide.remove", function() {
252  
-						$(this).remove();
253  
-					});
  251
+					if( !self.thisPage.data("page").options.domCache ){
  252
+						self.thisPage.bind( "pagehide.remove", function() {
  253
+							$(this).remove();
  254
+						});
  255
+					}
254 256
 
255 257
 					// doesn't solve the possible issue with calling change page
256 258
 					// where the objects don't define data urls which prevents dialog key
65  tests/unit/select/cached-dom-cache-true.html
... ...
@@ -0,0 +1,65 @@
  1
+<!DOCTYPE HTML>
  2
+<html lang="en">
  3
+  <head>
  4
+    <meta charset="utf-8">
  5
+  </head>
  6
+  <body>
  7
+    <div id="dialog-select-parent-domcache-test" data-nstest-role="page" data-nstest-dom-cache="true">
  8
+	    <div data-nstest-role="fieldcontain" id="domcache-page-select-container">
  9
+		    <label for="domcache-page-select" class="select">Your state:</label>
  10
+		    <select name="domcache-page-select" id="domcache-page-select" data-nstest-native-menu="false">
  11
+			    <option value="AL">Alabama</option>
  12
+			    <option value="AK">Alaska</option>
  13
+			    <option value="AZ">Arizona</option>
  14
+			    <option value="AR">Arkansas</option>
  15
+			    <option value="CA">California</option>
  16
+			    <option value="CO">Colorado</option>
  17
+			    <option value="CT">Connecticut</option>
  18
+			    <option value="DE">Delaware</option>
  19
+			    <option value="FL">Florida</option>
  20
+			    <option value="GA">Georgia</option>
  21
+			    <option value="HI">Hawaii</option>
  22
+			    <option value="ID">Idaho</option>
  23
+			    <option value="IL">Illinois</option>
  24
+			    <option value="IN">Indiana</option>
  25
+			    <option value="IA">Iowa</option>
  26
+			    <option value="KS">Kansas</option>
  27
+			    <option value="KY">Kentucky</option>
  28
+			    <option value="LA">Louisiana</option>
  29
+			    <option value="ME">Maine</option>
  30
+			    <option value="MD">Maryland</option>
  31
+			    <option value="MA">Massachusetts</option>
  32
+			    <option value="MI">Michigan</option>
  33
+			    <option value="MN">Minnesota</option>
  34
+			    <option value="MS">Mississippi</option>
  35
+			    <option value="MO">Missouri</option>
  36
+			    <option value="MT">Montana</option>
  37
+			    <option value="NE">Nebraska</option>
  38
+			    <option value="NV">Nevada</option>
  39
+			    <option value="NH">New Hampshire</option>
  40
+			    <option value="NJ">New Jersey</option>
  41
+			    <option value="NM">New Mexico</option>
  42
+			    <option value="NY">New York</option>
  43
+			    <option value="NC">North Carolina</option>
  44
+			    <option value="ND">North Dakota</option>
  45
+			    <option value="OH">Ohio</option>
  46
+			    <option value="OK">Oklahoma</option>
  47
+			    <option value="OR">Oregon</option>
  48
+			    <option value="PA">Pennsylvania</option>
  49
+			    <option value="RI">Rhode Island</option>
  50
+			    <option value="SC">South Carolina</option>
  51
+			    <option value="SD">South Dakota</option>
  52
+			    <option value="TN">Tennessee</option>
  53
+			    <option value="TX">Texas</option>
  54
+			    <option value="UT">Utah</option>
  55
+			    <option value="VT">Vermont</option>
  56
+			    <option value="VA">Virginia</option>
  57
+			    <option value="WA">Washington</option>
  58
+			    <option value="WV">West Virginia</option>
  59
+			    <option value="WI">Wisconsin</option>
  60
+			    <option value="WY">Wyoming</option>
  61
+		    </select>
  62
+	    </div>
  63
+    </div>
  64
+  </body>
  65
+</html>
31  tests/unit/select/select_cached.js
@@ -67,4 +67,35 @@
67 67
 			start
68 68
 		]);
69 69
 	});
  70
+	
  71
+	asyncTest( "dialog sized select shouldn't rebind its parent page remove handler when closing, if the parent page domCache option is true", function(){
  72
+		expect( 3 );
  73
+
  74
+		$.testHelper.pageSequence([
  75
+			resetHash,
  76
+
  77
+			function(){
  78
+				$.mobile.changePage( "cached-dom-cache-true.html" );
  79
+			},
  80
+
  81
+			function(){
  82
+				$.mobile.activePage.find( "#domcache-page-select" ).siblings( 'a' ).click();
  83
+			},
  84
+
  85
+			function(){
  86
+				ok( $.mobile.activePage.hasClass('ui-dialog'), "the dialog came up" );
  87
+				$.mobile.activePage.find( "li a" ).last().click();
  88
+			},
  89
+
  90
+			function(){
  91
+				ok( $.mobile.activePage.is( "#dialog-select-parent-domcache-test" ), "the dialog closed" );
  92
+				$.mobile.changePage( $( "#default" ) );
  93
+			},
  94
+
  95
+			function(){
  96
+				same( $("#dialog-select-parent-domcache-test").length, 1, "make sure the select parent page is still cached in the dom after changing page" );
  97
+				start();
  98
+			}
  99
+		]);
  100
+	});
70 101
 })(jQuery);

0 notes on commit 866b1b0

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