jQueryUI自动完成只使用对话框一次

时间:2016-10-12 10:56:09

标签: jquery jquery-ui autocomplete

重新打开后,对话框自动完成功能不起作用。

var create_product = function () {
    isEdit = false;
    $(".dialog_create_product").dialog({
        autoOpen: true,
        width: 800,
        modal: true,
        buttons: {},
        open: function (event, ui) {
    =>      $( ".getInputComponent" ).autocomplete({
                source: ['1','2','3'],
            });
        },
        close: function (event, ui) {
            $(".dialog_create_product").dialog("destroy")
        },
        beforeClose: function (event, ui) {
            closeDialog();
        }
    });
};

HTML

<div class="divInput"align="center">
    <input class = "getInputComponent" placeholder="name" type="text" maxlength="50"><button class="addComponent" >Add</button>
</div>

即使自动完成语句超出对话框功能。

$(".dialog_create_product").on( "dialogopen", function( event, ui ) {$( ".getInputComponent" ).autocomplete({source: ['1','2','3']});} );

$(document).on( "dialogopen", function( event, ui ) {$( ".getInputComponent" ).autocomplete({source: ['1','2','3']});} );

1 个答案:

答案 0 :(得分:0)

你写了

close: function (event, ui) {
     $(".dialog_create_product").dialog("close")
},

转入此

close: function (event, ui) {
         $(this).dialog('destroy').remove()
},