0

以下代码在常规视图中工作正常,但在部分视图中不能正常工作

<script>
$.noConflict();
var uniqueId = '@Guid.NewGuid().ToString()';
jQuery(document).ready(function ($) {


    console.log(uniqueId);
    $("#Myform input[name='clientId']").val(uniqueId);
    console.log($("#Myform input[name='clientId']").val());

    var bar = $('.progress-bar');
    var percent = $('.percent');
    var status = $('#status');

    $('#Myform').ajaxForm({
        beforeSend: function () {
            status.empty();
            var percentVal = '0%';
            bar.width(percentVal);
            percent.html(percentVal);
            $("#pleaseWaitDialog").modal({ backdrop: 'static', keyboard: false });
            $('#statusBorder').show();

            //$("#pleaseWaitDialog").modal({ backdrop: 'static', keyboard: false });
        },
        uploadProgress: function (event, position, total, percentComplete) {

            var percentVal = percentComplete + '%';
            bar.width(percentVal);
            percent.html(percentVal);
        },
        complete: function (xhr) {
            getStatus();
            status.html(xhr.responseText);
            //$("#pleaseWaitDialog").modal('hide');
        }
    });
});
</script>

我有一个错误“$(...).ajaxform 不是函数”

这是我已经尝试过的:

  1. 使用 javascript 库调用的位置进行操作
  2. 仔细检查是否存在 javascript/jquery 库调用冲突
4

1 回答 1

1

页面加载时未加载部分视图。

您必须强制在加载局部视图后调用该函数。

你正在这样做:

  1. 按事件触发器(由用户在部分视图中发生)
  2. 通过页面的事件触发。
  3. 标签中的贾斯特

最优雅的方式是前两个选项。

于 2017-10-26T09:18:04.220 回答