如何从Autocomplete插件中的formatResult获取CODE?

时间:2011-10-02 19:22:40

标签: javascript jquery search jquery-plugins jquery-autocomplete

我有这个:

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 + ") ";
    }
});

这段代码运行良好,但我无法获取代码,因为在formatResult函数中,行$('#code_to_use').val( row.code );永远不会执行或发生了什么?

0 个答案:

没有答案