Jquery自动完成其他属性

时间:2012-08-22 14:23:14

标签: jquery html jquery-ui

目前我正在尝试将其他值从我的数据库传递到自动填充文本字段,但发现它不成功。

以下是我当前自动填充功能的javascript代码。

    var fullurl = app.php
    $.getJSON(fullurl, function(result) {
        var elements = [];
        $.each(result, function(i, val) {
            elements.push(val.name);
        });

        $('#App').autocomplete({
            source : elements,
            minLength : 0
        }).focus(function() {
            if ($(this).autocomplete('widget').is(':visible')) {
                return;
            }
            $(this).data('autocomplete').search($(this).val());
        });
    });

目前,只要通过autocompelte

选择了一个选项,就会返回以下html
<input type="text" rel="" id="App" class="input-xlarge ui-autocomplete-input" autocomplete="off" role="textbox" aria-autocomplete="list" aria-haspopup="true">

因此,一旦我使用简单的jquery语句检查所选值是什么,我只得到应用程序名称。

var searched = $('#App').val(); //returns my value

如何将一些其他数据传递到我的自动填充中,例如rel属性中的App ID值。因此,当我写下面的内容时,我也会获得应用程序ID。

var searched = $('#App').val(); //returns my value
var applicationID = $('#App').attr('rel'); //how do I implement this? the AppID should get passed thru the db.

谢谢。

0 个答案:

没有答案
相关问题