【问题标题】:error in opening Ajax Modal打开 Ajax 模态时出错
【发布时间】:2015-04-14 09:09:18
【问题描述】:

我目前正在用 MVC C# 构建一个 webapp。我想打开一个弹出窗口,用户可以在其中输入大量信息,这样他就可以创建一个新的“用户”。但是我无法让窗口实际弹出。稍后,我也想关闭窗口,虽然我怀疑我得到这个后会很麻烦。以下是我目前的代码:

<button class='btn btn-lg btn-default giveMeSomeSpace leaveMeAlone createUser dialog' onclick='createNewApplication()'>Create a new application</button>

<div class="modal" id="modal-new-app" tabindex="-1" role="dialog" aria-labelledby="modal-new-app" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            ...
            <div class="modal-body">

            </div>
        </div>
    </div>
</div>
...

function createNewApplication() {
    $.ajax({
        url: '@Html.Raw(@Url.Action("Create", "User"))',
        success: function (data) {
            $("#modal-body").html(data);
        },
        cache: false
    });

    $('#modal-new-app').modal('show');

}

编辑:更正了一个错字,尽管那不是错误。此外,我在 Chrome 开发工具控制台中遇到的错误:

Uncaught TypeError: undefined is not a function

参考

$('#modal-new-app').modal('show');

【问题讨论】:

    标签: c# jquery ajax model-view-controller popup


    【解决方案1】:

    我和我的大学一直在寻找,我们得到了它的工作。

    <div class="modal" id="modal-new-app" tabindex="-1" role="dialog" aria-labelledby="modal-new-app" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                        <button type="button" class="close cancel" data-dismiss="modal"><span aria-hidden="true">&times;</span>
                                <span class="sr-only">Close</span></button>
                        <h4 class="modal-title">Create a new user</h4>
                    </div>
                <div class="modal-body">
    
                </div>
            </div>
        </div>
    </div>
    

    .

    $(document).ready(function () {
         createNewApplication();
         $('#tableApps').DataTable();
    
    });
    
    function createNewApplication() {
        $.get('@Html.Raw(@Url.Action("Create", "UserIS"))', function (data) {
            $('#modal-new-app .modal-body').html(data);           
        });
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-28
      • 2014-09-12
      相关资源
      最近更新 更多