>

asp.net mvc 프로젝트를하고 있는데 아래와 같이 볼 수 있습니다 :

<div class="content-wrapper">
         <div class="bs-example wow fadeInUp animated" data-wow-delay=".5s" data-example-id="contextual-table" style="border: 1px solid #eee">
                <table class="table table-bordered" id="">
                    <tr style="background-color: #555555; color: white">
                        <th>
                            @Html.DisplayNameFor(model => model.contractId)
                        </th>
                        <th>
                            @Html.DisplayNameFor(model => model.Customer.IdentificationNo)
                        </th>
                        <th>
                            @Html.DisplayNameFor(model => model.Device.DeviceId)
                        </th>
                        <th>
                            @Html.DisplayNameFor(model => model.Vehicle.Vin)
                        </th>
                        <th></th>
                    </tr>
                    @foreach (var item in Model)
                    {
                        <tr>
                            <th>
                                @Html.DisplayFor(modelItem => item.contractId)
                            </th>
                            <td>
                                @Html.DisplayFor(modelItem => item.Customer.IdentificationNo)
                            </td>
                            <td>
                                @Html.DisplayFor(modelItem => item.Device.DeviceId)
                            </td>
                            <td>
                                @Html.DisplayFor(modelItem => item.Vehicle.Vin)
                            </td>
                            <td>
                                <a class="anchorDetail btn btn-1 btn-info" onclick="ContractDetail(@item.Id)">جزئیات</a>
                            </td>
                        </tr>
                    }
                </table>
            </div>
        </div>

<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLable">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h5 class="modal-title" id="myModalLable">Modal title</h5>
            </div>
            <div class="modal-body" id="myModalBody">
                ...
            </div>
        </div>
    </div>
</div>

<script>
    function ContractDetail(Id) {
        $.ajax({
            url: "/Contract/EditContract/",
            type: "Get",
            data: { Id: Id }
        }).done(function (result) {
            $("#myModal").modal();
            $("#myModalLable").html("ویرایش قرارداد");
            $("#myModalBody").html(result);
        });
    }
</script>

이 뷰에서 jquery 함수로 액션을 호출하고 싶습니다. 동작은 다음과 같습니다.

public ActionResult EditContract(int Id)
    {
        if (Id == 0)
        {
            return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
        }
        Contract contract = db.Contract.Where(c => c.Id == Id && c.IsDeleted != true).Select(c => c).SingleOrDefault();
        if (contract == null)
        {
            return HttpNotFound();
        }
        return PartialView("EditContract", contract);
    }

이 작업은 부분보기를 반환합니다. 부분보기는 다음과 같습니다.

   @model DataLayer.Contract
    @{
        Layout = null;
    }
    <body class="hold-transition register-page">
        <div class="register-box">
            <div class="register-logo">
                <b>ویرایش قرارداد</b>
            </div>
            <div class="register-box-body">

                @using (Ajax.BeginForm("EditContract", "Contract", FormMethod.Post, new AjaxOptions()
                {
                    OnSuccess = "success",
                    UpdateTargetId = "listUsers"
                }))
                {
                    @Html.AntiForgeryToken()
                    @Html.HiddenFor(model => model.IsDeleted)
                    @Html.HiddenFor(model => model.Fr_CustomerId)
                    @Html.HiddenFor(model => model.Fr_DeviceId)
                    @Html.HiddenFor(model => model.Fr_VehicleId)
                    @Html.HiddenFor(model => model.CustomerIdentificationNo)

                    <div class="form-group row">
                        <div class="col-md-12 row">
                            @Html.LabelFor(model => model.Id, htmlAttributes: new { @class = "control-label col-md-12" })
                        </div>
                        <div class="form-group has-feedback">
                            @Html.EditorFor(model => model.Id, new { htmlAttributes = new { @disabled = "true", @class = "form-control" } })
                            @Html.ValidationMessageFor(model => model.Id, "", new { @class = "text-danger" })
                        </div>
                    </div>
                    <div class="form-group row">
                        <div class="col-md-12 row">
                            @Html.LabelFor(model => model.PublicId, htmlAttributes: new { @class = "control-label col-md-12" })
                        </div>
                        <div class="form-group has-feedback">
                            @Html.EditorFor(model => model.PublicId, new { htmlAttributes = new { @disabled = "true", @class = "form-control" } })
                            @Html.ValidationMessageFor(model => model.PublicId, "", new { @class = "text-danger" })
                        </div>
                    </div>
                    <div class="form-group row">
                        <div class="col-md-12 row">
                            @Html.LabelFor(model => model.CreateDate, htmlAttributes: new { @class = "control-label col-md-12" })
                        </div>
                        <div class="form-group has-feedback">
                            @Html.EditorFor(model => model.CreateDate, new { htmlAttributes = new { @disabled = "true", @class = "form-control" } })
                            @Html.ValidationMessageFor(model => model.CreateDate, "", new { @class = "text-danger" })
                        </div>
                    </div>
                    <div class="form-group row">
                        <div class="col-md-12 row">
                            @Html.LabelFor(model => model.RegistererUser, htmlAttributes: new { @class = "control-label col-md-12" })
                        </div>
                        <div class="form-group has-feedback">
                            @Html.EditorFor(model => model.RegistererUser, new { htmlAttributes = new { @disabled = "true", @class = "form-control" } })
                            @Html.ValidationMessageFor(model => model.RegistererUser, "", new { @class = "text-danger" })
                        </div>
                    </div>
                    <div class="form-group row">
                        <div class="col-md-12 row">
                            @Html.LabelFor(model => model.C_key, htmlAttributes: new { @class = "control-label col-md-12" })
                        </div>
                        <div class="form-group has-feedback">
                            @Html.EditorFor(model => model.C_key, new { htmlAttributes = new { @disabled = "true", @class = "form-control" } })
                            @Html.ValidationMessageFor(model => model.C_key, "", new { @class = "text-danger" })
                        </div>
                    </div>
                    <div class="form-group row">
                        <div class="col-md-12 row">
                            @Html.LabelFor(model => model.C_id, htmlAttributes: new { @class = "control-label col-md-12" })
                        </div>
                        <div class="form-group has-feedback">
                            @Html.EditorFor(model => model.C_id, new { htmlAttributes = new { @disabled = "true", @class = "form-control" } })
                            @Html.ValidationMessageFor(model => model.C_id, "", new { @class = "text-danger" })
                        </div>
                    </div>
                    <div class="form-group row">
                        <div class="col-md-12 row">
                            @Html.LabelFor(model => model.C_rev, htmlAttributes: new { @class = "control-label col-md-12" })
                        </div>
                        <div class="form-group has-feedback">
                            @Html.EditorFor(model => model.C_rev, new { htmlAttributes = new { @disabled = "true", @class = "form-control" } })
                            @Html.ValidationMessageFor(model => model.C_rev, "", new { @class = "text-danger" })
                        </div>
                    </div>
                    <div class="form-group row">
                        <div class="col-md-12 row">
                            @Html.LabelFor(model => model.contractId, htmlAttributes: new { @class = "control-label col-md-12" })
                        </div>
                        <div class="form-group has-feedback">
                            @Html.EditorFor(model => model.contractId, new { htmlAttributes = new { @disabled = "true", @class = "form-control" } })
                            @Html.ValidationMessageFor(model => model.contractId, "", new { @class = "text-danger" })
                        </div>
                    </div>
                    <div class="form-group row">
                        <div class="col-md-12 row">
                            @Html.LabelFor(model => model.deviceId, htmlAttributes: new { @class = "control-label col-md-12" })
                        </div>
                        <div class="form-group has-feedback">
                            @Html.EditorFor(model => model.deviceId, new { htmlAttributes = new { @disabled = "true", @class = "form-control" } })
                            @Html.ValidationMessageFor(model => model.deviceId, "", new { @class = "text-danger" })
                        </div>
                    </div>
                    <div class="form-group row">
                        <div class="col-md-12 row">
                            @Html.LabelFor(model => model.vehicleId, htmlAttributes: new { @class = "control-label col-md-12" })
                        </div>
                        <div class="form-group has-feedback">
                            @Html.EditorFor(model => model.vehicleId, new { htmlAttributes = new { @disabled = "true", @class = "form-control" } })
                            @Html.ValidationMessageFor(model => model.vehicleId, "", new { @class = "text-danger" })
                        </div>
                    </div>
                    <div class="form-group row">
                        <div class="col-md-12 row">
                            @Html.LabelFor(model => model.vid, htmlAttributes: new { @class = "control-label col-md-12" })
                        </div>
                        <div class="form-group has-feedback">
                            @Html.EditorFor(model => model.vid, new { htmlAttributes = new { @disabled = "true", @class = "form-control" } })
                            @Html.ValidationMessageFor(model => model.vid, "", new { @class = "text-danger" })
                        </div>
                    </div>
                    <div class="form-group row">
                        <div class="col-md-12 row">
                            @Html.LabelFor(model => model.cid, htmlAttributes: new { @class = "control-label col-md-12" })
                        </div>
                        <div class="form-group has-feedback">
                            @Html.EditorFor(model => model.cid, new { htmlAttributes = new { @disabled = "true", @class = "form-control" } })
                            @Html.ValidationMessageFor(model => model.cid, "", new { @class = "text-danger" })
                        </div>
                    </div>
                    <div class="form-group row">
                        <div class="col-md-12 row">
                            @Html.LabelFor(model => model.did, htmlAttributes: new { @class = "control-label col-md-12" })
                        </div>
                        <div class="form-group has-feedback">
                            @Html.EditorFor(model => model.did, new { htmlAttributes = new { @disabled = "true", @class = "form-control" } })
                            @Html.ValidationMessageFor(model => model.did, "", new { @class = "text-danger" })
                        </div>
                    </div>
                    <div class="form-group row">
                        <div class="col-md-12 row">
                            @Html.LabelFor(model => model.CustomerIdentificationNo, htmlAttributes: new { @class = "control-label col-md-12" })
                        </div>
                        <div class="form-group has-feedback">
                            @Html.EditorFor(model => model.CustomerIdentificationNo, new { htmlAttributes = new { @disabled = "true", @class = "form-control" } })
                            @Html.ValidationMessageFor(model => model.CustomerIdentificationNo, "", new { @class = "text-danger" })
                        </div>
                    </div>

                    <div class="form-group has-feedback">
                        @Html.EditorFor(model => model.StartTime, new { htmlAttributes = new { @class = "", placeholder = Html.DisplayNameFor(x => x.StartTime) } })
                        @Html.ValidationMessageFor(model => model.StartTime, "", new { @class = "text-danger" })
                    </div>
                    <div class="form-group has-feedback">
                        @Html.EditorFor(model => model.EndTime, new { htmlAttributes = new { @class = "", placeholder = Html.DisplayNameFor(x => x.EndTime) } })
                        @Html.ValidationMessageFor(model => model.EndTime, "", new { @class = "text-danger" })
                    </div>
                    <div class="form-group has-feedback">
                        @Html.EditorFor(model => model.StartMilage, new { htmlAttributes = new { @class = "form-control", placeholder = Html.DisplayNameFor(x => x.StartMilage) } })
                        @Html.ValidationMessageFor(model => model.StartMilage, "", new { @class = "text-danger" })
                    </div>
                    <div class="form-group has-feedback">
                        @Html.EditorFor(model => model.state, new { htmlAttributes = new { @class = "form-control", placeholder = Html.DisplayNameFor(x => x.state) } })
                        @Html.ValidationMessageFor(model => model.state, "", new { @class = "text-danger" })
                    </div>
                    <div class="row">
                        <a class="btn btn-warning" id="EditContract">ویرایش قرارداد</a>
                        <a class="btn btn-danger" id="DeleteContract">پاک کردن قرارداد</a>
                        <a class="btn btn-normal">بروز رسانی</a>
                    </div>
                }
            </div>
        </div>
    </body>



    <link href="http://cdn.kendostatic.com/2013.2.918/styles/kendo.common.min.css" rel="stylesheet">
<link href="http://cdn.kendostatic.com/2013.2.918/styles/kendo.default.min.css" rel="stylesheet">
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="/Content/js/kendo.all.min.js"></script>
<script>
    $(document).ready(function () {
    $("#StartTime").kendoDatePicker();
        $("#EndTime").kendoDatePicker();
    });
</script>

모달이 나타나는 동안 kendoDatePicker의 캘린더가 모달에서 열리지 않는 이유는 무엇입니까?

  • 답변 # 1

    이것은 JS의 타이밍 문제입니다. 모달이로드 된 후 날짜 선택기 코드를 실행해야합니다.

    ...
    $("#myModalBody").html(result);
    // initialize kendo elements on partial
    $("#StartTime").kendoDatePicker();
    $("#EndTime").kendoDatePicker();
    
    

  • 답변 # 2

    문제는 jquery 버전에있었습니다. 내 문제는

    <script src="code.jquery.com/jquery-1.9.1.min.js"></script>
    
    

    으로

    <script src="code.jquery.com/jquery-migrate-3.0.0.min.js">
    
    

관련 자료

  • 이전 yaml - 동적 gitlab-ci 파일을 설정하는 방법
  • 다음 java - 모든 숫자를 고려한 반올림 숫자