1

Final Update - I'm marking this question resolved. I ended up going with Bootstrap Suggest for what I needed.

Update - With help from this post and some comments, I've been able to get this working with Input fields. I need some help getting it to run with div, span, or something that can take in text in-line.

I'm having trouble getting autocomplete or keydown events to trigger on dynamically created spans.

As you can see in my JSFiddle, I can bind the click event on the new element and it works fine, but neither the keydown or autocomplete seems to work. Does Autocomplete HAVE to be on an input field? I thought it could work on the span (which is the whole reason I was creating the span in the first place).

I've tried following existing posts (like the ones listed below) but I've had no luck.

What could I be doing wrong? Am I overlooking something obvious? I've set breakpoints in the autocomplete function and it literally never hits them

Joe Morgan
  • 1,761
  • 6
  • 20
  • 29
  • Hi, you can see [here](https://jsfiddle.net/tk3ewvhz/) its working fine on inputs . – Swati May 17 '21 at 15:38
  • Thanks for the follow-up, @Swati. I'm now able to get it to work with inputs. I need it to be able to flow better than a whole separate input field within the div, though. Would it be possible to create a div, span, or something that would flow in-line? I basically need to be able to autocomplete like a social media platform does with hashtags – Joe Morgan May 17 '21 at 16:15
  • 1
    Then try [this](https://bootstrap-tagsinput.github.io/bootstrap-tagsinput/examples/) plugin it has autocomplete feature as well. – Swati May 18 '21 at 04:04

1 Answers1

0

Use Bootstrap-Suggest instead of trying roll my own.

Joe Morgan
  • 1,761
  • 6
  • 20
  • 29