动态添加的Html输入页面选项卡按钮不工作

Dynamically Added Html Inputs Page Tab Button Not Working

本文关键字:选项 按钮 工作 添加 Html 输入 动态      更新时间:2023-09-26

我正在添加动态HTML内容到我的弹出显示在下面

$.get(url, function (data) {
    swal({
        title: "",
        text: data,
        html: true,
        showCancelButton: false,
        showConfirmButton: false,
        customClass: "dialog",
        allowOutsideClick: true,
        allowEscapeKey: true
    },
    function() {
        console.log('');
    });

这是我的动态html内容

 @using (Html.BeginForm("GetSendMessagePopUp", "Help", FormMethod.Post, new {enctype = "multipart/form-data", id = "questionModelForm"}))
    {
        <div>
            @Html.TextBoxFor(item => item.FullName, new { style = "display: block"})
        </div>
        <div>            
            @Html.TextBoxFor(item => item.Phone, new {style = "display: block"})
        </div>
        <div>            
            @Html.TextAreaFor(item => item.Message, new {style = "display: block"})
        </div>
        <a href="javascript:void(0)" onclick="sendUserMessage()" class="helpButton">Gönder</a>
    }
</div>

一切正常,除了选项卡按钮不能聚焦另一个字段。

我在下面的开发人员面板中尝试过,但仍然不起作用

$('.dialog input').tabs();
$('.dialog input').tabs('refresh');

也添加这段代码:

$.ajaxComplete(function () {
  $('.dialog input').tabs();
  $('.dialog input').tabs('refresh');
  // And whatever you wanna load fresh, after the AJAX call is completed.
});

From sweetalert.js我注释了tab键的默认值,然后它开始正常工作

// TAB
    if (btnIndex === -1) {
        // No button focused. Jump to the confirm button.
        $targetElement = $okButton;
    } else {
        // Cycle to the next button
        if (btnIndex === $modalButtons.length - 1) {
            $targetElement = $modalButtons[0];
        } else {
            $targetElement = $modalButtons[btnIndex + 1];
        }
    }
    _stopEventPropagation$fireClick.stopEventPropagation(e);
    $targetElement.focus();
    if (params.confirmButtonColor) {
        _setFocusStyle.setFocusStyle($targetElement, params.confirmButtonColor);
    }

我删除了这行,它可以正常工作