开发者

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

Accessing JSON object after event completed

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜