Autocomplet in stache not working


#1

Hi all,

I am a bit confused running easy-autocomplete within a can.view.callbacks setup.
I created a JS Bin with two input fields.
The first defined in the “regular” body environment, the second initialized via callbacks.attr.

The first one works, the second does not. Any idea what I am doing wrong?

Cheers,

Nada


#2

Looks like the JSBin doesn’t have your code. Can you update the link?


#3

Uups…
Link is updated now


#4

Doesn’t anybody have at least a hint?


#5

Hi @nada, sorry for not responding sooner!

When the callbacks function runs, the input is created but it’s not yet added to the DOM. For some cases, this is helpful because the element will already have any modifications made to it before it’s added to the DOM, but in this case the other library doesn’t work well in this scenario.

To work around it, you can just wrap the easyComplete call with a setTimeout, like in this JS Bin: https://bitovi-jsbin.jsbin.com/reragak/1/edit?html,js,output