This repository was archived by the owner on May 29, 2019. It is now read-only.
File tree 3 files changed +12
-10
lines changed
3 files changed +12
-10
lines changed Original file line number Diff line number Diff line change @@ -24,8 +24,8 @@ The typeahead directives provide several attributes:
24
24
* ` typeahead-append-to-body ` <i class =" glyphicon glyphicon-eye-open " ></i >
25
25
_ (Defaults: false)_ : Should the typeahead popup be appended to $body instead of the parent element?
26
26
27
- * ` typeahead-append-to-element-id `
28
- _ (Defaults: false )_ : Should the typeahead popup be appended to an element id instead of the parent element?
27
+ * ` typeahead-append-to `
28
+ _ (Defaults: null )_ : Should the typeahead popup be appended to an element instead of the parent element?
29
29
30
30
* ` typeahead-editable `
31
31
_ (Defaults: true)_ :
@@ -85,4 +85,4 @@ The typeahead directives provide several attributes:
85
85
86
86
* ` typeahead-show-hint `
87
87
_ (Defaults: false)_ :
88
- Should input show hint that matches the first option?
88
+ Should input show hint that matches the first option?
Original file line number Diff line number Diff line change @@ -967,7 +967,7 @@ describe('typeahead tests', function() {
967
967
expect ( $scope . result ) . toEqual ( $scope . states [ 0 ] ) ;
968
968
} ) ;
969
969
} ) ;
970
-
970
+
971
971
describe ( 'input hint' , function ( ) {
972
972
var element ;
973
973
@@ -1047,10 +1047,11 @@ describe('typeahead tests', function() {
1047
1047
} ) ;
1048
1048
} ) ;
1049
1049
1050
- describe ( 'append to element id ' , function ( ) {
1050
+ describe ( 'append to' , function ( ) {
1051
1051
it ( 'append typeahead results to element' , function ( ) {
1052
1052
$document . find ( 'body' ) . append ( '<div id="myElement"></div>' ) ;
1053
- var element = prepareInputEl ( '<div><input name="input" ng-model="result" uib-typeahead="item for item in states | filter:$viewValue" typeahead-append-to-element-id="myElement"></div>' ) ;
1053
+ $scope . myElement = $document . find ( '#myElement' ) ;
1054
+ var element = prepareInputEl ( '<div><input name="input" ng-model="result" uib-typeahead="item for item in states | filter:$viewValue" typeahead-append-to="myElement"></div>' ) ;
1054
1055
changeInputValueTo ( element , 'al' ) ;
1055
1056
expect ( $document . find ( '#myElement' ) ) . toBeOpenWithActive ( 2 , 0 ) ;
1056
1057
$document . find ( '#myElement' ) . remove ( ) ;
Original file line number Diff line number Diff line change @@ -61,7 +61,8 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position'])
61
61
62
62
var appendToBody = attrs . typeaheadAppendToBody ? originalScope . $eval ( attrs . typeaheadAppendToBody ) : false ;
63
63
64
- var appendToElementId = attrs . typeaheadAppendToElementId || false ;
64
+ var appendTo = attrs . typeaheadAppendTo ?
65
+ originalScope . $eval ( attrs . typeaheadAppendTo ) : null ;
65
66
66
67
var focusFirst = originalScope . $eval ( attrs . typeaheadFocusFirst ) !== false ;
67
68
@@ -423,7 +424,7 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position'])
423
424
424
425
originalScope . $on ( '$destroy' , function ( ) {
425
426
$document . unbind ( 'click' , dismissClickHandler ) ;
426
- if ( appendToBody || appendToElementId ) {
427
+ if ( appendToBody || appendTo ) {
427
428
$popup . remove ( ) ;
428
429
}
429
430
@@ -443,8 +444,8 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position'])
443
444
444
445
if ( appendToBody ) {
445
446
$document . find ( 'body' ) . append ( $popup ) ;
446
- } else if ( appendToElementId !== false ) {
447
- angular . element ( $document [ 0 ] . getElementById ( appendToElementId ) ) . append ( $popup ) ;
447
+ } else if ( appendTo ) {
448
+ angular . element ( appendTo ) . eq ( 0 ) . append ( $popup ) ;
448
449
} else {
449
450
element . after ( $popup ) ;
450
451
}
You can’t perform that action at this time.
0 commit comments