0

現在、AJAX の投稿が成功した場合にダイアログ ボックスが表示されるように設定しています。AJAX の投稿は成功しましたが (以下のアラートが発生しています)、ダイアログ ボックスが表示されません。理由がわかりません。ここに私のマークアップがあります:

<a data-eventid="@item.EventId" id="raffle-@item.EventId" class="raffle-charity-button" href="#"><img src="~/Images/Raffle.png" alt="Raffle" title="Pick a winner!"/></a>

<div id="raffle-event-dialog">
    <p class="dialogDisplayWinner">
    </p>
</div>

...そして、ここに私のスクリプトがあります:

$(".raffle-charity-button").click(function() {
            charityEventId = $(this).data("eventid");
            //charityEventId = parseInt($(this).attr("id").split("-")[1]);
            var url = "@Url.Action("Raffle", "DonationEvent")";
            var postData = {
                id: charityEventId
            };
            $.ajax({
                type: "POST",
                url: url,
                data: postData,
                datatype: "json",
                success:
                    function(data) {
                        if (data != "") {
                            if (data.Success == "false") {
                                window.location = "../Error";
                            } else {
                                var originalVerbiage = "The winner of the raffle is... "
                                $(".dialogDisplayWinner").empty();
                                $(".dialogDisplayWinner").append(originalVerbiage + "test");

                                $("#raffle-event-dialog").dialog({
                                        modal: true,
                                        autoOpen: false,
                                        buttons: {
                                            "OK": function() {
                                                $("#raffle-event-dialog").dialog("close");
                                            }
                                        },
                                        resizable: false
                                    }
                                );
                                alert(data.Success);
                            }
                        }
                    },
                error:
                    function(jqxhr, ajaxOptions, thrownError) {
                        alert("An error occurred: error Code(" + jqxhr.status + ") message: " + jqxhr.responseText);
                    }
            });
        });

私が見落としているのは明らかですか?これは可能ですか?

4

2 に答える 2

1

オプションautoOpenを に設定してダイアログを作成してfalseいるため、ダイアログは自動的には開きません (こちらのドキュメントを確認してください)。この値を次のように変更するtrueか、呼び出して後でダイアログを開きます。

$("#raffle-event-dialog").dialog('open');
于 2013-07-02T11:50:26.063 に答える
1

コードでは、autoOpen 属性は false です。ダイアログを自動的に開くには、「true」に設定します。

$("#raffle-event-dialog").dialog({
         modal: true,
         autoOpen: true,
         buttons: {
         "OK": function() {
             $("#raffle-event-dialog").dialog("close");
            }
          },
          resizable: false
        }
 );
于 2013-07-02T11:52:04.670 に答える