'How to get CODE from formatResult in an Autocomplete plugin?

I have this:

var objects_list = [{
    "code": "44",
    "name": "Privilegios de cuenta",
    "alias": "account-privileges",
    "typename": "Opci\u00f3n",
    "typealias": "object",
    "description": null
}, {
    "code": "104",
    "name": "Asignar aplicaciones",
    "alias": "add-application-to-user",
    "typename": "Opci\u00f3n",
    "typealias": "object",
    "description": "Permite asignar aplicaciones a las cuentas"
}];
$('#find_object').autocomplete(objects_list, {
    minChars: 0,
    width: 310,
    matchContains: "word",
    autoFill: false,
    formatItem: function(row, i, max) {
        return "<b>" + row.name + "</b>" + " (" + row.description + ")";
    },
    formatMatch: function(row, i, max) {
        return row.name + " " + row.alias + " " + row.description + " " + row.typename + " " + row.typealias;
    },
    formatResult: function(row) {
          $('#code_to_use').val( row.code );
          return row.name + " (" + row.description + ") ";
    }
});

This code works well, but I can't understand the code very clearly. In the formatResult function, the line $('#code_to_use').val( row.code ) is never executed or did I get it wrong?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source