From 5dc93007a54ab4f5aa16b2791daf752e378596cf Mon Sep 17 00:00:00 2001 From: keith Date: Sun, 16 Aug 2015 12:49:02 -0700 Subject: [PATCH 1/2] feat(typeahead): add `typeaheadAppendToElementId` --- src/typeahead/typeahead.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/typeahead/typeahead.js b/src/typeahead/typeahead.js index db661ba0ca..6c887b6490 100644 --- a/src/typeahead/typeahead.js +++ b/src/typeahead/typeahead.js @@ -67,6 +67,8 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position', 'ui.bootstrap var appendToBody = attrs.typeaheadAppendToBody ? originalScope.$eval(attrs.typeaheadAppendToBody) : false; + var appendToElementId = attrs.typeaheadAppendToElementId || false; + var focusFirst = originalScope.$eval(attrs.typeaheadFocusFirst) !== false; //If input matches an item of the list exactly, select it automatically @@ -419,6 +421,8 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position', 'ui.bootstrap if (appendToBody) { $document.find('body').append($popup); + } else if(appendToElementId !== false) { + $document.find('#' + appendToElementId).append($popup); } else { element.after($popup); } From c4aa9f7a43aa69c8640bc981f1dd9d48dd3e5805 Mon Sep 17 00:00:00 2001 From: keith Date: Tue, 18 Aug 2015 14:29:40 -0700 Subject: [PATCH 2/2] feat(typeahead): add test --- src/typeahead/test/typeahead.spec.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/typeahead/test/typeahead.spec.js b/src/typeahead/test/typeahead.spec.js index 92a75de3f4..b8b814ad41 100644 --- a/src/typeahead/test/typeahead.spec.js +++ b/src/typeahead/test/typeahead.spec.js @@ -818,6 +818,14 @@ describe('typeahead tests', function() { }); }); + describe('append to element id', function() { + it('append typeahead results to element', function() { + var element = prepareInputEl('
'); + changeInputValueTo(element, 'ba'); + expect($document.find('#myElement')).toBeOpenWithActive(2, 0); + }); + }); + describe('append to body', function() { it('append typeahead results to body', function() { var element = prepareInputEl('
');