JQuery UI 自动完成多个(多个输入的多个值)

JQuery UI Autocomplete Multiple(Multiple Values for Multiple Input)

我在网上找不到答案。

这是我的输入框:

<div class="form-group">
    <div id="prefetch">
        <label for="external_name" class="font-weight-bold">Choose External File as Reference</label>
        <input type="text" name="external_name" id="external_name" class="form-control" placeholder="External File"/>
        <input type="hidden" name="external_id" id="external_id" class="form-control" value='-'/>
        <small>*Previous value : <?php if(empty($sedata->external_name) == FALSE){echo $sedata->external_name;}else{echo "-";} ?></small>
    </div>
</div>

这是我的 jquery 代码:

         $("#external_name").autocomplete({
            source: function (request, response) {
                // Fetch data
                $.ajax({
                    url: "<?php echo base_url('Se/acexternalrefse') ?>",
                    type: 'post',
                    dataType: "json",
                    data: {
                        search: request.term
                    },
                    success: function (data) {
                        response(data);
                    }
                });
            },
            select: function (event, ui) {
                // Set selection
                $('#external_name').val(ui.item.label); // display the selected text
                $('#external_id').val(ui.item.value); // save selected id to input
                return false;
            }
        });

这是来自模型和控制器的数据:

public function ac_externalref_se($postData){
        $response = array();

        if(isset($postData['search']) ){
            $records = $this->db->select('*')->order_by('external_name','ASC')->like('external_name', $postData['search'],'both')->limit(10)->get('external')->result();
            foreach($records as $row ){
                $response[] = array("value"=>$row->external_id,"label"=>$row->external_name);
            }
        }

        return $response;
    }

        public function acexternalrefse(){
        $postData   =   $this->input->post();
        $data       =   $this->SE_model->ac_externalref_se($postData);

        echo json_encode($data);
    }

输出将允许您选择 1 个值,而不是多个 对于输入文本 external_name 和输入隐藏 external_id

我不明白如何为多个输入获取多个值 喜欢:

输入文本外部名称的值=PHP、Java、JavaScript

输入文本外部 id 的值 = 1、5、9

如果你有做多select多输入的经验jqueryUI自动完成请与我分享怎么做,我是js新手, jquery,jquery-UI.....

nvm,我找到了答案: https://makitweb.com/jquery-ui-autocomplete-with-php-and-ajax/

并添加

focus: function() {
   return false;
},