fix #315 AutoComplete JS error when clicking the dropdown button

Fixing a regression after b1eb1323439bc3f3203ef5b0c3880410105e8715 using
the similar solution as in 1c8d106816f790fa65465660ee9a6b9ab375af50.

Pull request #316.