How can I pass another hit attribute field into onchange not the selected value

const autocomplete = instantsearch.connectors.connectAutocomplete(
({ indices, refine, widgetParams }, isFirstRendering) => {
const { container, onSelectChange } = widgetParams;

if (isFirstRendering) {
  container.html('<select id="ais-autocomplete"></select>');

  container.find('select').selectize({
    options: [],
    valueField: 'spell',
    labelField: 'spell',
    searchField: 'spell',

    highlight: false,
    onType: refine,
     onBlur() {
     refine(this.getValue());
    },
  
     score() {
        return function() {
         return 1;
       };
     },


     onChange(value) {

       //// *** here I want to get the value of a hit attribute field not value

       onSelectChange(value);
       refine(value);
     },
  });

  return;
}

const [select] = container.find('select');

indices.forEach(index => {
  select.selectize.clearOptions();
  index.results.hits.forEach(h => select.selectize.addOption(h));
  select.selectize.refreshOptions(select.selectize.isOpen);
});

}
);

Hi @chris9,

This question is not related to Algolia in general but more about the plugin selectize. The onChange event exposes the value of the input. You can use it to get the original value from this.options[value]. The result is undefined when the input is cleared.

container.find("select").selectize({
  // ...

  onChange(value) {
   console.log(this.options[value])
  },
});

Hope that helps!