【问题标题】:jQueryUI autocomplete working with dialog just oncejQueryUI 自动完成只使用一次对话框
【发布时间】:2016-10-12 10:56:09
【问题描述】:

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

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']});} );

【问题讨论】:

  • 你能详细解释一下,你到底想要什么?
  • 我多次使用对话框。打开它做一些更改并保存它。但是当我第二次打开我的对话框时,自动完成表单是空的。如果我使用.dialog("close"),它的工作正常,但我应该使用.dialog("destroy"),而我使用destroy 有一个错误。

标签: jquery jquery-ui autocomplete


【解决方案1】:

你写的

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

改成这个

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

【讨论】:

  • 关闭此对话框后不再打开
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-09-12
  • 2013-10-19
  • 1970-01-01
  • 2012-02-29
  • 2011-10-29
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多