javascript - Autocomplete jQueryUI double call function on select and press enter -
i'd little help. here's jsfiddle : https://jsfiddle.net/mirawen/q59nqh2z/
function keypress(keyevent) { if (keyevent.which == 13) mainfunction(); } function mainfunction() { alert("hello world"); } var arrsource = ["foo", "foooo", "foooooo", "bar", "barr", "barr"]; $(document).ready(function() { $("#txtsearch").autocomplete({ source: arrsource, minlength: 1, select: function (event, ui) { mainfunction(); } }); });
when press enter, want call mainfunction()
, , call function when select item autocomplete point is, when select item , press enter, mainfunction()
called twice.
don't know how solve this.
thanks answers !
i think calling same function twice on same event,so calling main function twice. if press enter keypress/keyup/keydown event. so, when document ready, getting called once , gets called on enter keypress event.
Comments
Post a Comment