Q:

Examine JSON populating Struts autocompleter

I have a select box populated by JSON using a Struts autocompleter:
<sj:autocompleter 
    id="stop" 
    name="stopId"
    href="%{stopsUrl}" 
    list="stops" 
    listValue="stopName" 
    listKey="stopId" 
    autocomplete="true"
    loadMinimumCount="2"
    delay="200"
    tabindex="1"
    onSelectTopics="onStopSelected"
/> 

This makes an Ajax request to stopsUrl that returns a list of stops objects each of which has a stopId and a stopName as well as a stopType.
I need to save the stopType somewhere (I guess by using JQuery data function), and then when the user selects a stop, the onStopSelected function will retrieve the stopType and do something with it.
So I think I'll need to examine the data in the JSON response to get the stopType for each stop. But how can I access this? Which event do I need to subscribe to? Is it possible using Struts?

A:

Maybe there's a better way, but I've done it like this.
I've deleted the line onSelectTopics="onStopSelected" that was in the question, and instead use (old) jQuery to read the JSON in the autocompleteopen event:
$( "#stop_widget" ).live( "autocompleteopen", function() {
    var stops = $(this).data("autocomplete").response.caller.arguments[0].stops;
    var stopTypes = {};
    for (var i = 0; i < stops.length; i++) {
        stopTypes[stops[i].stopId] = stops[i].stopType;
    }
    $("#stop").data("stopTypes", stopTypes);
});

Then in the autocompleteselect event, I can access the stopType:
$("#stop_widget").bind( "autocompleteselect", function(event,data){
    var selectedStopId = data.item.key;
    var stopTypes = $("#stop").data("stopTypes");
    var selectedStopType = stopTypes[selectedStopId];
    // do something with the selectedStopType
});

