jquery自动完成和jQuery UI对话框

时间:2022-12-15 20:30:38

I have a question about how to collaborate auto complete with UI dialog:

我有一个关于如何使用UI对话框协作自动完成的问题:

  1. There is an input text which enables autocomplete (the data is not a simple string array, so it needs to be parsed). This job is well done:

    有一个输入文本可以启用自动完成(数据不是简单的字符串数组,因此需要进行解析)。这项工作做得很好:

    <input type="text" id="styleno" name="styleno" >
    
    $("#styleno").autocomplete("${suggest}", {
                    parse:function(raw){
                 var parsed = [];
                 for (var i=0; i < raw.model.length; i++) {    
    
                    var row = raw.model[i];
                    parsed.push({
                        data: row,
                       value: row,
                      result: row.styleNo
                    });
                 }
                 return parsed;
    
            },
            formatMatch: function(row, i, max) {
                     return row.styleNo;
                    },
                    formatItem: function(data, i, n, value) {
                    //
    
                            return  data.id+data.styleNo;
                    }
            });
    
  2. When a result is selected from the suggested list, I want to open a dialog, populate somethings from the parsed the result. So I use the "result" function:

    当从建议列表中选择结果时,我想打开一个对话框,从解析结果中填充一些东西。所以我使用“结果”功能:

    $("#styleno").result(function(data,values){
            $('#itemDiv').dialog('open');
    }
    

    The dialog is opened, but the focus is kept on the auto suggested input field (<input type="text" id="styleno" name="styleno" >). So I use this code:

    对话框打开,但焦点保留在自动建议的输入字段上()。所以我用这个代码:

    $("#styleno").trigger("unautocomplete");
    

    Now the dialog is fine, but the input field lost its autosuggestion capability.

    现在对话框很好,但输入字段失去了自动提供功能。

What shall I do? According to the selected item from suggestion list, then pop up a dialog with some input field. After user fills the field in the dialog, close it, get back to auto suggested field still use the auto suggestion function.

我该怎么办?根据建议列表中的选定项目,然后弹出一个带有一些输入字段的对话框。用户填写对话框中的字段后,关闭它,返回自动建议字段仍然使用自动建议功能。

1 个解决方案

#1


Not 100% sure it works like this, but you might try the following:

不是100%确定它是这样的,但您可以尝试以下方法:

$("#styleno").blur();

Sounds like the event you are looking for.

听起来像你正在寻找的事件。

#1


Not 100% sure it works like this, but you might try the following:

不是100%确定它是这样的,但您可以尝试以下方法:

$("#styleno").blur();

Sounds like the event you are looking for.

听起来像你正在寻找的事件。