0

テレリックポップアップウィンドウがあります。それはうまく開きます。ただし、ウィンドウを閉じる際に問題が発生します。javascript、alert( "#Window")またはalert($(this).closest('#Window'))にアラートを追加すると、[オブジェクトオブジェクト]が表示されます。ただし、alter( "#Window")。data( "tWindow")またはalert($(this).closest('#Window')。data('tWindow'))はnullを表示します。親ページまたは子ページのいずれかからjqueryとjavascriptの参照を削除しましたが、違いはありませんでした。どんな種類の助けも大歓迎です。以下のサンプルコードを参照してください

ポップアップウィンドウは次のとおりです。

@{Html.Telerik().Window()
     .Name("Window")
     .Title("Student Window")
     .LoadContentFrom(Url.Action("AddReason", "Reason", new { id = reasonID }, Request.Url.Scheme))
     .ClientEvents(events => events
         .OnClose("ClosingWindow")
         )
     .Draggable(false)
     .Scrollable(false)
     .Width(800)
     .Height(600)
     .Modal(true)
     .Visible(false)
     //.Effects(fx => fx
     //    .Zoom()
     //    .Opacity())
     .Render();
 }

JavaScriptは次のとおりです。

  <script src="@Url.Content("~/Scripts/jquery-1.4.4.js")" type="text/javascript">

</script>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/spin.min.js")" type="text/javascript"></script>


function DoOpen(id) {
        var url = '@Url.Action("AddReason","Reason")';
        $.post(url, { id: id }, function (data) {
            var window = $('#Window').data('tWindow').center();
            window.content(data);
            window.open();
        });
   }
 //This javascript is in the main page
//I did an alert. alert($('#Window')) and 
alert($('#Window').data('tWindow')) they both return null

  function ClosingWindow() {
      $('#Window').prop("checked", "checked");
      $('#Window').data('tWindow').close();
       window.location.href = window.location.href;
   }

Here is the partial view :

    @model Student.Models.Reason
@using Student.Example

@{
    ViewBag.Title = "Add Reason";
    Layout = "~/Views/Shared/_PartialReason.cshtml";
}

<script type="text/javascript">
    function CloseWindow() {
//        alert($("#Window").closest('.t-window').data('#tWindow'));
//        $("#Window").data("tWindow").close();
        $('#Window').prop("checked", "checked");
         window.location.href = window.location.href;
    }

</script>

@using (Html.BeginForm("AddReason", "Reason", FormMethod.Post))
{
    @Html.ValidationSummary(true)
    <fieldset>
        <div class="editor-field">
            @(Html.Telerik().Editor()
            .Name("EncountersArchive")
            .HtmlAttributes(new { style = "height:310px;", id = "AddAReason" })
            .Encode(true)
            .Tools(
            tools => tools
                       .Clear()
                        .Bold().Italic().Underline().Strikethrough().Subscript().Superscript().Separator()
                        .FontName().FontSize()
                        .FontColor().BackColor().Separator()
                        .JustifyLeft().JustifyCenter().JustifyRight().JustifyFull().Separator()
                        .InsertUnorderedList().InsertOrderedList().Separator()
                        .Indent().Outdent().Separator()
            ))
        </div>
        <p style="text-align:center">

            <input type="submit" value="Reason" id="AddReasonID" onclick="CloseWindow()"/>
        </p>
    </fieldset>
}
4

1 に答える 1

0

ポップアップウィンドウのOnCloseイベントが問題の原因でした。oncloseイベントは、ウィンドウが閉じられた後にユーザーが何か他のことをしたい場合にのみ使用する必要があります。目的が単にウィンドウを閉じることである場合、Telerikコントロールは自動的にウィンドウを処理します。私の場合、oncloseイベントを削除するだけで、チャームのように機能します。

于 2013-04-05T01:57:06.723 に答える