1

所以这是从输入中调用两个变量的问题,在“#key”变量上,最后一次调用数据库中的“split(this.value);” 让它像这样

//这可以

touser: karen galante, jor monucha, wappa who,

//这需要

rnkey:凯伦·加兰特,乔尔·蒙努查,gdhdf9j7hd98fg7dfn,

// nappppaa8686f86df8,iuof79f79ds7h8j7kg70gfd70fg8dsf,gdhdf9j7hd98fg7dfn,

我是 jquery ui 的新手,我已经在这段代码上工作了几天,任何想法

$(function() {
    var availableTags = [
    {
            value: "iuof79f79ds7h8j7kg70gfd70fg8dsf",
            label: "jor monucha",
            desc: "the write less, do more, JavaScript library",
            icon: "16.png"
    },
            {
            value: "nappppaa8686f86df8",
            label: "karen galante",
            desc: "the write less, do more, JavaScript library",
            icon: "16.png"
    },        {
            value: "gdhdf9j7hd98fg7dfn",
            label: "wappa who",
            desc: "the write less, do more, JavaScript library",
            icon: "16.png"
    },
        ];
    function split( val ) {
        return val.split( /,\s*/ );
    }
    function extractLast( term ) {
        return split( term ).pop();
    }

    $( "#tags" )
        // don't navigate away from the field on tab when selecting an item
        .bind( "keydown", function( event ) {
            if ( event.keyCode === $.ui.keyCode.TAB &&
                    $( this ).data( "autocomplete" ).menu.active ) {
                event.preventDefault();
            }
        })
        .autocomplete({
            minLength: 2,
            source: function( request, response ) {
                // delegate back to autocomplete, but extract the last term
                response( $.ui.autocomplete.filter(
                    availableTags, extractLast( request.term ) ) );
            },
            focus: function() {
                // prevent value inserted on focus
                return false;

            },







       select: function( event, ui ) {
            $( "#project" ).val( ui.item.label );
            $( "#project-id" ).val( ui.item.value );
            $( "#project-description" ).html( ui.item.desc );
            $( "#project-icon" ).attr( "src", "images/" + ui.item.icon );


                var hintkey = split( this.value );
                // remove the current input
                hintkey.pop();
                // add the selected item
                hintkey.push( ui.item.value );
                // add placeholder to get the comma-and-space at the end
                hintkey.join( ", " );
                hintkey.push( "" );

                $( "#key" ).val(hintkey);

                var terms = split( this.value );
                // remove the current input
                terms.pop();
                // add the selected item
                terms.push( ui.item.label );
                // add placeholder to get the comma-and-space at the end
                terms.push( "" );
                this.value = terms.join( ", " );
4

0 回答 0