@@ -77,10 +77,13 @@ $.widget( "mobile.table", $.mobile.table, {
7777 } ) ;
7878 } ,
7979
80- _addToggles : function ( menu ) {
80+ _addToggles : function ( menu , keep ) {
8181 var opts = this . options ;
82+
8283 // allow update of menu on refresh (fixes #5880)
83- menu . empty ( ) ;
84+ if ( ! keep ) {
85+ menu . empty ( ) ;
86+ }
8487
8588 // create the hide/show toggles
8689 this . headers . not ( "td" ) . each ( function ( ) {
@@ -92,13 +95,15 @@ $.widget( "mobile.table", $.mobile.table, {
9295 if ( priority ) {
9396 $cells . addClass ( opts . classes . priorityPrefix + priority ) ;
9497
95- $ ( "<label><input type='checkbox' checked />" + $this . text ( ) + "</label>" )
96- . appendTo ( menu )
97- . children ( 0 )
98- . data ( "cells" , $cells )
99- . checkboxradio ( {
100- theme : opts . columnPopupTheme
101- } ) ;
98+ if ( ! keep ) {
99+ $ ( "<label><input type='checkbox' checked />" + $this . text ( ) + "</label>" )
100+ . appendTo ( menu )
101+ . children ( 0 )
102+ . data ( "cells" , $cells )
103+ . checkboxradio ( {
104+ theme : opts . columnPopupTheme
105+ } ) ;
106+ }
102107 }
103108
104109 } ) ;
@@ -146,8 +151,8 @@ $.widget( "mobile.table", $.mobile.table, {
146151 $popup = $ ( "<div data-" + ns + "role='popup' data-" + ns + "role='fieldcontain' class='" + opts . classes . popup + "' id='" + id + "'></div>" ) ;
147152 $menu = $ ( "<fieldset data-" + ns + "role='controlgroup'></fieldset>" ) ;
148153
149- // set extension here
150- this . _addToggles ( $menu ) ;
154+ // set extension here, send "false" to trigger build/rebuild
155+ this . _addToggles ( $menu , false ) ;
151156
152157 $menu . appendTo ( $popup ) ;
153158
@@ -160,6 +165,13 @@ $.widget( "mobile.table", $.mobile.table, {
160165 return $menu ;
161166 } ,
162167
168+ rebuild : function ( ) {
169+ // NOTE: rebuild passes "false", while refresh passes "undefined"
170+ // both refresh the table, but inside addToggles, !false will be true,
171+ // so a rebuild call can be indentified
172+ this . refresh ( false ) ;
173+ } ,
174+
163175 refresh : function ( create ) {
164176 this . _super ( create ) ;
165177
@@ -168,7 +180,7 @@ $.widget( "mobile.table", $.mobile.table, {
168180 this . _unlockCells ( this . allHeaders ) ;
169181
170182 // update columntoggles and $cells
171- this . _addToggles ( this . _menu ) ;
183+ this . _addToggles ( this . _menu , create ) ;
172184
173185 // check/uncheck
174186 this . _setToggleState ( ) ;
0 commit comments