Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Typeahead append element to div with id #4231

Closed
wants to merge 2 commits into from
Closed

Typeahead append element to div with id #4231

wants to merge 2 commits into from

Conversation

trueinviso
Copy link

I'd like to add this feature so that the typeahead popup can be appended to another div. This works on my site, however I can't get the test to pass. I can see the popup get appended inside typeahead.js when I put in log statements. However, the popup doesn't display when text is entered into the input field. Suggestions?

@@ -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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be noted that this library does not have a dependency on jQuery, so this would fail with purely jqLite.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One workaround here is to do $document[0].getElementById(appendToElementId)

@wesleycho
Copy link
Contributor

What is the use case for such a feature? This sounds like it would be bad for accessibility.

@trueinviso
Copy link
Author

I need the results to be appended under the Popular Searches heading in this screen shot. My solution was to append the popup to the div using typeahead-append-to-element-id.

screenshot

@wesleycho
Copy link
Contributor

The test needs to be fixed.

@wesleycho
Copy link
Contributor

Ahh, I know why it fails the test - the element doesn't exist on the DOM - in the test, just do $document.find('body').append(element) and remove it after the test with element.remove(); element = null; (for gc reasons).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants