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

时间:2015-08-17 10:24:54

标签: javascript c# jquery html

我正在向我的弹出窗口添加动态HTML内容,如下所示

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

这是我的dynamicHtml内容

 @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');

2 个答案:

答案 0 :(得分:1)

添加这段代码:

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

答案 1 :(得分:0)

从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);
    }

我删除了这一行而不是正常工作