0

JQM の新しいアルファ リリースでネストされたポップアップが表示されないのに苦労しています。たとえば、ユーザーが入力することになっているポップアップ フォームを表示しています。サーバー側の検証が失敗した場合、エラー ポップアップを表示したいと考えています。エラーポップアップが表示されていないことがわかりました。元のポップアップの下に表示されていると思われます。

function bindSongWriterInvite() {

    // Bind the click event of the invite button
    $("#invite-songwriter").click(function () {
        $("#songwriter-invite-popup").popup("open");
    });

    // Bind the invitation click event of the invite modal
    $("#songwriter-invite-invite").click(function () {
        if ($('#songwriter-invite').valid()) {
            $('#songwriter-invite-popup').popup('close');
            $.ajax({
                type: 'POST',
                async: true,
                url: '/songwriter/jsoncreate',
                data: $('#songwriter-invite').serialize() + "&songName=" + $("#Song_Title").val(),
                success: function (response) {
                    if (response.state != "success") {
                        alert("Should be showing error dialog");
                        mobileBindErrorDialog(response.message);
                    }
                    else {
                        mobileBindErrorDialog("Success!");
                    }
                },
                failure: function () {
                    mobileBindErrorDialog("Failure!");
                },
                dataType: 'json'
            });
        }
    });

    // Bind the cancel click event of the invite modal
    $("#songwriter-invite-cancel").click(function () {
        $("#songwriter-invite-popup").popup("close");
    });
}

function mobileBindErrorDialog(errorMessage) {
    // Close all open popups.  This is a work around as the JQM Alpha does not
    // open new popups in front of all other popups.
    var error = $("<div></div>").append("<p>" + errorMessage + "</p>")
                                .popup();
    $(error).popup("open");
}

したがって、ajax の投稿が成功するか失敗するかに関係なく、エラー ダイアログを表示しようとしていることがわかります。それは決して現れません。

誰にも考えはありますか?

マイク

4

1 に答える 1

0

解決策を見つけました!

bindErrorPopup 関数に遅延を設定して、ポップアップを閉じるアニメーションが完了するまで待機します。

function mobileBindErrorDialog(errorMessage, delay) {
    var error = $("<div></div>").attr({
        'data-rel': "popup",
        'data-theme': "a"
    });

    $(error).append("<p>" + errorMessage + "</p>")
            .popup({
                overlayTheme: "a",
                positionTo: "window",
                theme: "a"
            });

    setTimeout(function () {
        $(error).popup("open");
    }, delay);
}

素晴らしい作品!

于 2012-09-03T23:57:20.920 に答える