jquery移动按钮没有出现

时间:2013-11-21 16:15:25

标签: javascript jquery html jquery-mobile cordova

我正在使用jquery mobile 1.3.2,每当我按下按钮时,按钮会显示被按下的样式,但之后它再也不会恢复。

HTML:

<form id="login_form">
<input type="text" name="username">
<input type="password" name="password">
<button type="submit" data-theme="b" data-role="submit">Login</button>
</form>

使用Javascript:

$("#login_form").submit(function()
{
    $.mobile.allowCrossDomainPages = true;
    var options = {
        url:API_SERVER_URL+"/login",
        type: "post",
        success: function(data)
        {
            if (data.success)
            {

                $.mobile.changePage('success.html', {transition: "slide"});
            }else
            {
                alert("failed:("); 
            }
        },
        error: function()
        {
            alert('cannot connect');
        }
    };
    options = $.extend(DEFAULT_AJAX_OPTIONS, options);
    $(this).ajaxSubmit(options);
    return false;
});

How it looks after being pressed

1 个答案:

答案 0 :(得分:1)

提交表单时删除ui-btn-active

$("#login_form").on("submit", function () {
  $("[type=submit]").closest('div').removeClass("ui-btn-active");
});
  

<强> Demo