Sunday, 15 April 2012

jquery autocomplete focus show all firing after unfocus -



jquery autocomplete focus show all firing after unfocus -

if select jquery autocomplete list, saves thing clicked database. working well. when click want autocomplete close, clear value out of input, , unfocus/blur input no longer active. working. next step show total list on input focus, can see available before start typing. working.

the part gives me problem autocomplete firing twice when click something. example: click list, select part working (it saves thing clicked , updates list), closes autocomplete en blurs input. fires autocomplete again. disappears second, returns while input not in focus.

this code:

var availabletags<?=$options['id']?> = "/url/to/list/with/tags"; $(".autocomplete<?=$options['id']?>").autocomplete({ source: availabletags<?=$options['id']?>, delay: 500, disabled: <?=$disabledjs?>, minlength: 0, select: function(event, ui) { var click_koppeling_id = ui.item.value; var item_id = "<?=$values['id']?>"; var tabel = "<?=$modulemodel?>"; var koppeltabel = "<?=$koppelingmodelnaam?>"; $.ajax({ url: '/url/to/post', type: 'post', data: {click_koppeling_id: click_koppeling_id, item_id: item_id, tabel:tabel, koppeltabel:koppeltabel}, success: function(data, textstatus, xhr){ console.log(data); if(data == "success"){ $("#koppeltabeldiv<?=$options['id']?>").load("/link/to/new/list/with/added/thing"); } else { //show error } }, }); $(this).val(""); $(this).blur(); $(this).autocomplete("close"); homecoming false; }, }).focus(function(){ $(this).autocomplete("search"); });

does know why fires sec time? isn't supposed to.

i still haven't figured out solution, changed things solve question. removed focus part:

.focus(function(){ $(this).autocomplete("search"); });

next input field made button, 1 time click triggers total list displayed. workaround works way want to.

if in future has solution question, still hear it! workaround works fine me.

jquery autocomplete jquery-autocomplete

No comments:

Post a Comment