sergiodlopes / jquery-flexdatalist

Flexible input autocomplete/datalist plugin for jQuery
http://projects.sergiodinislopes.pt/flexdatalist/
MIT License
364 stars 84 forks source link

$.focus() on a flexdatalist field doesn't work #235

Open mLamneck opened 2 years ago

mLamneck commented 2 years ago

I try to set the focus on an input field using

$('#field_id').focus()

and the field doesn't get the focus. If I remove the flexdatalist class from the field that should get the focus it works.

What am I doing wrong here?

mLamneck commented 2 years ago

I found a solution. Flexdatalist creates a new input element with a different id and hides the original one. In order to set the focus to a flexdalist input it works with

$(#field_id-flexdatalist).focus()

if the original field has the id field_id. I don't know if this is a good solution, but it works.