question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Attaching typeahead behavior to dynamically added elements

See original GitHub issue

I am trying to figure out how to add the typeahead behavior to a dynamically added element. I now catch the onInsert event for the new typeahead elements and add the properties (below). However, I don’t get the typeahead behavior.

prefetch: '/words.json',
valueKey: 'name',
limit: 30,
template: [
'<p class="repo-name">{{name}}</p>',
'<p class="repo-description">{{description}}</p>'
].join(''),
engine: Hogan

Can anyone help me on how to add the typeahead behavior to a dynamically added element?

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
jhardingcommented, May 29, 2013

It seems like you’re not calling jQuery#typeahead on the dynamically added input element. You should be doing something like this:

$('<input>').appendTo('body').typeahead({ /* ... */ });
0reactions
ParthBarot-BoTreeConsultingcommented, Jul 8, 2015

@jharding Thanks, Your comment worked for me. I was trying to bind it inside keyup for the new dynamically added element, but instead we can use this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Twitter typeahead - adding suggestion to dynamically created ...
I'm using Twitter typeahead create a suggestion engine for some input boxes on a form. Everything works fine for inputs that are generated...
Read more >
jQuery Typeahead Search Configuration - RunningCoder
Create a jQuery object using a unique input selector. Then chain the .typeahead() function containing parameters as an object. 1. 2. 3.
Read more >
Initializing Dynamically Appended HTML Elements In ... - Telerik
I have specific fields that users can customize their events with, if they add these fields, they dynamically show up in the event ......
Read more >
Auto-complete for the Dynamic Form Tag Helper
One way to implement auto-complete for a form text field is to place a list element <ul> somewhere under the <input> field. Then,...
Read more >
react-bootstrap-typeahead - npm
Installation. npm install --save react-bootstrap-typeahead. or yarn add react-bootstrap-typeahead. Include the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found