File tree 2 files changed +25
-3
lines changed
2 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ uis.directive('uiSelect',
43
43
44
44
$select . onSelectCallback = $parse ( attrs . onSelect ) ;
45
45
$select . onRemoveCallback = $parse ( attrs . onRemove ) ;
46
-
46
+
47
47
//Set reference to ngModel from uiSelectCtrl
48
48
$select . ngModel = ngModel ;
49
49
@@ -190,7 +190,7 @@ uis.directive('uiSelect',
190
190
191
191
// Support for appending the select field to the body when its open
192
192
var appendToBody = scope . $eval ( attrs . appendToBody ) ;
193
- if ( appendToBody !== undefined ? appendToBody : uiSelectConfig . appendToBody ) {
193
+ if ( ( appendToBody !== undefined ? appendToBody : uiSelectConfig . appendToBody ) || attrs . appendTo ) {
194
194
scope . $watch ( '$select.open' , function ( isOpen ) {
195
195
if ( isOpen ) {
196
196
positionDropdown ( ) ;
@@ -225,7 +225,11 @@ uis.directive('uiSelect',
225
225
originalWidth = element [ 0 ] . style . width ;
226
226
227
227
// Now move the actual dropdown element to the end of the body
228
- $document . find ( 'body' ) . append ( element ) ;
228
+ if ( attrs . appendTo ) {
229
+ $document . find ( attrs . appendTo ) . append ( element ) ;
230
+ } else {
231
+ $document . find ( 'body' ) . append ( element ) ;
232
+ }
229
233
230
234
element [ 0 ] . style . position = 'absolute' ;
231
235
element [ 0 ] . style . left = offset . left + 'px' ;
Original file line number Diff line number Diff line change @@ -105,6 +105,7 @@ describe('ui-select tests', function() {
105
105
if ( attrs . taggingTokens !== undefined ) { attrsHtml += ' tagging-tokens="' + attrs . taggingTokens + '"' ; }
106
106
if ( attrs . title !== undefined ) { attrsHtml += ' title="' + attrs . title + '"' ; }
107
107
if ( attrs . appendToBody != undefined ) { attrsHtml += ' append-to-body="' + attrs . appendToBody + '"' ; }
108
+ if ( attrs . appendTo != undefined ) { attrsHtml += ' append-to="' + attrs . appendTo + '"' ; }
108
109
if ( attrs . allowClear != undefined ) { matchAttrsHtml += ' allow-clear="' + attrs . allowClear + '"' ; }
109
110
}
110
111
@@ -1849,6 +1850,23 @@ describe('ui-select tests', function() {
1849
1850
} ) ;
1850
1851
} ) ;
1851
1852
1853
+ describe ( 'select with the appendTo option' , function ( ) {
1854
+ var body ;
1855
+
1856
+ beforeEach ( inject ( function ( $document ) {
1857
+ body = $document . find ( 'body' ) [ 0 ] ;
1858
+ } ) ) ;
1859
+
1860
+ it ( 'should be moved to the end of an element when the appendTo option is a selector' , function ( ) {
1861
+ var parent = document . createElement ( 'DIV' ) ;
1862
+ parent . className = 'content-append' ;
1863
+ document . body . appendChild ( parent ) ;
1864
+ var el = createUiSelect ( { appendTo : '.content-append' } ) ;
1865
+ openDropdown ( el ) ;
1866
+ expect ( el . parent ( ) [ 0 ] ) . toBe ( parent ) ;
1867
+ } ) ;
1868
+ } ) ;
1869
+
1852
1870
describe ( 'select with the append to body option' , function ( ) {
1853
1871
var body ;
1854
1872
You can’t perform that action at this time.
0 commit comments