I have implemented JQuery Autocomplete UI and attached it with a textbox in my page
I have already written focusout() event for that textbox.
It was working fine till now. But I did some changes in my JQuery Autocomplete binding as per suggestions. Please find the code for autocomplete UI below.
$(":input[autocompletesource]").each(function () {
$(this)
.autocomplete(
{
select: function (event, ui) {
$(this).val(ui.item.label);
$($(this).attr('hiddencontrolname')).val(ui.item.value);
},
source: $(this).attr("autocompletesource"),
change: function (event, ui) {
// provide must match checking if what is in the input is in the list of results. HACK!
var source = $(this).val();
var found = false;
$('.ui-autocomplete li').filter(function () {
if (ui.item != null) {
if (ui.item.value.toString() == source.toString()) {
found = true;
return;
}
}
});
if (found == false) {
$(this).val('');
}
else {
$(this).val(ui.item.label);
var parentSelector = '#' + $(this)[0].id;
$(parentSelector).trigger("focusout");
}
}
});
});
Now, this is working fine. It perfectly selects the value and updates it in attached textbox. (Thanks to the responses in my previous thread) But this has stopped firing "focusout" event of that textbox. I tried executing that forcefully by using ".trigger"
method (you can find in above code, the call to focusout is added newly), but that also does not help. Any idea, why this would be happening? Thanks
nirman.doshi
Participant
1520 Points
775 Posts
focusout - does not get triggered.
Sep 16, 2011 06:15 AM|LINK
Hi,
I have implemented JQuery Autocomplete UI and attached it with a textbox in my page
I have already written focusout() event for that textbox.
It was working fine till now. But I did some changes in my JQuery Autocomplete binding as per suggestions. Please find the code for autocomplete UI below.
$(":input[autocompletesource]").each(function () { $(this) .autocomplete( { select: function (event, ui) { $(this).val(ui.item.label); $($(this).attr('hiddencontrolname')).val(ui.item.value); }, source: $(this).attr("autocompletesource"), change: function (event, ui) { // provide must match checking if what is in the input is in the list of results. HACK! var source = $(this).val(); var found = false; $('.ui-autocomplete li').filter(function () { if (ui.item != null) { if (ui.item.value.toString() == source.toString()) { found = true; return; } } }); if (found == false) { $(this).val(''); } else { $(this).val(ui.item.label); var parentSelector = '#' + $(this)[0].id; $(parentSelector).trigger("focusout"); } } }); });Now, this is working fine. It perfectly selects the value and updates it in attached textbox. (Thanks to the responses in my previous thread) But this has stopped firing "focusout" event of that textbox. I tried executing that forcefully by using ".trigger" method (you can find in above code, the call to focusout is added newly), but that also does not help. Any idea, why this would be happening? Thanks
Software Developer
Vadodara, India
Yanping Wang...
Star
14919 Points
1537 Posts
Microsoft
Re: focusout - does not get triggered.
Sep 20, 2011 02:49 AM|LINK
Hi nirman.doshi,
Please consider the alternative approaches to implement your requirement
move your markup in focusout() to blur() as asteranup's sample in blow post:
http://forums.asp.net/t/1709233.aspx/1?Suggestions+TextBox
hope this helps, thanks.
Feedback to us
Develop and promote your apps in Windows Store