$ .mobile.loading拒绝不工作

时间:2015-01-18 17:30:52

标签: javascript jquery jquery-mobile

正如标题所示,当用户点击按钮进行签名时,我希望调用$ .mobile.loading方法。现在这已经在网站上运行了50多次,但出于某种原因,下面的代码并没有打开$ .mobile.loading对话框,但它运行代码。不确定为什么会出现这种特殊情况。

<div id ="diaglogfacebookuserdetails" data-role="dialog" data-theme="a">
        <div data-role="header">
             <h3 class="headerdialog">Almost Done</h3>
        </div>
        <div data-role = "content">
            <center>
            <div class="alert-message info">
                    <div class="box-icon"><img src="css/images/info.svg"></div>
                    <div id="diaglogfacebookuserdetailsmessage"></div>
            </div>

            <input type="text" name="diaglogfacebookuserdetailscell" id="diaglogfacebookuserdetailscell" placeholder="Enter your Cell Number" />

            <select id="diaglogfacebookuserdetailsuni" class = "searchuniversity">
            </select>
            <select name="diaglogfacebookuserdetailscampus" id="diaglogfacebookuserdetailscampus" class = "signupuniversitycampus">
            </select>

            <input type="submit" id ="facebookuserdetailsbutton" name="facebookuserdetailsbutton" value="SUBMIT" data-theme="a"/>
            </center>
        </div>
    </div>

这是JS:

$(document).on('pageinit',"#diaglogfacebookuserdetails",

    function(){
    $("#facebookuserdetailsbutton").click(
                function()
                {
                    $.mobile.loading( 'show', {
                        text: 'Signing you Up!',
                        textVisible: true,
                        theme: 'a',
                        html: ""
                    });

                    //lots of Code

                   $.mobile.loading( 'hide' );

    });
});

1 个答案:

答案 0 :(得分:1)

因为您在显示后立即隐藏了加载对话框。尝试延迟关闭它(如此demo)或在数据成功上传到服务器时隐藏。

    setTimeout(function () {
        $.mobile.loading('hide');
    }, 1000);