繁体   English   中英

提交表单时,jQuery Mobile弹出窗口未打开

[英]Jquery mobile popup doesnt open on Submitting the form

我正在使用一个jquery mobile submit form将值保存到SQL database
将值成功存储到DB中后,将打开一个弹出窗口。

问题是单击提交按钮后,弹出窗口无法打开。 我需要单击2次以打开弹出窗口,而该弹出窗口又会添加2个数据库条目。

代码:

        <script type="text/javascript" >
        function BuyerDetails() {
            var keys = new Array();
            keys[0] = $('#boardingPassId').val();
            keys[1] = $('#MainContent_totalPrice').val();
            keys[2] = document.getElementById("select-choice-a").options[document.getElementById("select-choice-a").selectedIndex].text;
            keys[3] = $('#email').val();
            keys[4] = $('#Username').val();
            keys[5] = $('#Feedback').val();
            PageMethods.AddToBuyers(keys, onSuccess, onFailure);
        }

        function onSuccess(result) {
            $('#popupDiv').popup("open");
        }

        function onFailure(error) {
            alert(error);
        }
    </script>

HTML代码

<div id="page" data-role="page">
    <div data-theme="a" data-role="header" data-position="fixed">
        <h3 style="color: white;">Confirmation
        </h3>
        <a data-role="button" onclick="javascript:history.back()" class="ui-btn-left">Back</a>
        <a style="color: white;" data-role="button" data-ajax="false" href="Default.aspx">Home</a>
    </div>
    <div data-role="content">
        <div class="content-primary">
            <ul data-role="listview" data-inset="true">
                <li data-role="fieldcontain">
                    <label for="email">
                        Boarding pass Number</label>
                    <input id="boardingPassId" type="text" name="input" value="" />
                </li>
                <li data-role="fieldcontain">
                    <label for="email">
                        Name</label>
                    <input id="Username" type="text" name="input" value="" />
                </li>
                <li data-role="fieldcontain">
                    <label for="email">
                        Total Price</label>
                    <input type="text" name="input1" runat="server" id="totalPrice" readonly="readonly" />
                </li>
                <li data-role="fieldcontain">
                    <label for="email" class="select">
                        Payment Method</label>
                    <select name="select-choice-a" id="select-choice-a" data-native-menu="false" style="width: 500px;">
                        <option value="card">Card</option>
                        <option value="cash">Cash</option>
                    </select>
                </li>
                <li data-role="fieldcontain">
                    <label for="email">
                        Feedback(possible improvement/suggestions)</label>
                    <textarea cols="40" rows="8" name="textarea" id="Feedback"></textarea>
                </li>
                <li data-role="fieldcontain">
                    <label for="email">
                        Email id</label>
                    <input type="text" name="email" id="email" value="" />
                </li>
                <li class="ui-body ui-body-b">
                    <fieldset class="ui-grid-a">
                        <div class="ui-block-a">
                            <button type="submit" data-theme="d">
                                Cancel</button>
                        </div>
                        <div class="ui-block-b">
                            <button type="button" onclick="BuyerDetails()" data-theme="a">
                                Submit</button>
                        </div>
                    </fieldset>
                </li>
            </ul>
        </div>

        <div class="content-secondary">
            <div data-role="popup" id="popupDiv" data-theme="d" data-overlay-theme="b" class="ui-content"
                style="max-width: 340px;">
                <span id="dialog_title_span">Thank You</span>
                <p>
                    Your order has been placed
                </p>
                <a id="productPrice" data-role="button" data-theme="b" data-icon="check" data-inline="true"
                    href="Default.aspx" data-mini="true">DONE</a>
            </div>
        </div>
    </div>



</div>

任何帮助将不胜感激。

jQuery Mobile弹出窗口有点漏洞,主要是在Chrome浏览器中执行的。

经典的解决方法是:

$('#popupDiv').popup("open");

在setTimeout函数中:

setTimeout(function(){
    $('#popupDiv').popup("open");
},100);

1ms应该足够,但是您还应该使用其他值进行测试。

我还为您提供了一个有效的示例: http : //jsfiddle.net/Gajotres/4yvBK/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM