在表单提交上禁用Jquery UI按钮 [英] Disable Jquery UI Button on form submit

查看:78
本文介绍了在表单提交上禁用Jquery UI按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个这样的表格:

<form action="" method="post" id="form" name="form" enctype="multipart/form-data">
<input name="action" type="submit" value="Send" />
</form>

我使用的是最新版本的Jquery UI Button插件。必须提交提交按钮的值。是否有一种简单的方法可以在提交表单后禁用提交按钮,而无需使用其他插件,例如锁定提交 - http://plugins.jquery.com/project/LockSubmit

I am using the latest version of the Jquery UI Button plugin. The value of the submit button MUST be submitted. Is there an easy way to disable the submit button after the form has been submitted, without using additional plugins such as "Lock Submit" - http://plugins.jquery.com/project/LockSubmit ?

非常感谢。

推荐答案

设置元素的disabled属性时,不会提交。解决方法是在提交表单后设置禁用的属性。您可以使用 setTimeout() 延迟时间非常短的函数:

When you set the disabled property of an element, it won't be submitted. The workaround is to set the disabled property after the form is submitted. You can use the setTimeout() function with a very short delay:

$("#form").submit(function() {
    setTimeout(function() {
        // .prop() requires jQuery 1.6 or higher
        $("#form :submit").prop("disabled", true);
    }, 100);
});

在这里演示

另一个技巧,就是使用技巧:)你可以将原始提交按钮包装在一个内部表格提交时div和隐藏它。

Another trick, is to use a trick :) You can wrap the original submit button inside a div and hide it when the form submits.

在这里演示

这篇关于在表单提交上禁用Jquery UI按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆