Twitter typeahead autocomplete to dynamically added inputs

后端 未结 2 1592
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-12 13:18

I am using Twitter typeahead on my website and it works fine. But when I try to add new input dynamically it doesn\'t work. What could be the problem?

Thank you for

2条回答
  •  南笙
    南笙 (楼主)
    2021-01-12 13:49

    I have a very simple way to solve it, use the Function instead of Dynamic input. I mean: typeahead="item in calculatedInput($viewValue)"


    The root problem about using typeahead="item in $scope.dynamicArrayInput is: When the model change -> ng-change and typeahead fire event synchronize start So while calculatedInput() function doing something for get a dynamic input, the typeahead said model "jump in $scope.dynamicArrayInput then get something like $viewValue RIGHT NOW". And then filter $viewValue in []. When calculatedInput() finish his work, typeahead already found nothing and do not fire event until u change model one more time. So you always filter typeahead in (lastest - 1) dynamic array.

提交回复
热议问题