fix 315 AutoComplete JS error when clicking the dropdown button

See #315