Accessing JSON object after event completed
Context
I am using the jquery ui autocomplete control and that is working fine. From my understanding, this control is creating an unordered list and for each item in the list, the JSON object that I am asking for is "attached" to it. See image below
Some code
<ul class="ui-autocomplete ui-menu ui-widget ui-widget-content ui-corner-all" role="listbox" aria-activedescendant="ui-active-menuitem" style="z-index: 1; top: 444px; left: 48px; display: block; width: 118px;">
<li clas开发者_StackOverflow中文版s="ui-menu-item" role="menuitem"><a class="ui-corner-all" tabindex="-1">PartNum 1</a></li>
<li class="ui-menu-item" role="menuitem"><a class="ui-corner-all" tabindex="-1">PartNum 2</a></li>
Then on the close event of jquery ui autocomplete, I tried the following
close: function (event, ui) {
var termInput = $(this).val().toLowerCase();
var $autocompleteList = $('ul.ui-autocomplete li a');
$autocompleteList.each(function () {
if ($(this).text().toLowerCase() == termInput) {
var $parentItem = $(this).parent();
return;
}
});
EDIT - following a request for such an example
jsFiddle example
http://jsfiddle.net/mxzuF/
Question
How do I actually access these objects using jQuery outside of any "events" associated with jquery ui autocomplete? The fact is that I want to access these objects after the control has finished "executing". Effectively, I'm trying to access the objects associated with the $parentItem.
精彩评论