admin管理员组文章数量:1426507
I'm trying to write code that will disable submit button (or all submit buttons) on the page to avoid double postback.
I thought of generating my own postback javascript function (and inject postback javascript using GetPostbackEventReference
) but maybe there are some better ways to do this? Or maybe there is some other way to avoid double postbacks?
Update:
I also want to figure out the best place to call javascript, e.g. if I call following script in the onclick button handler then button's server click event won't be wired up.
$('input[type=submit]').attr('disabled', 'disabled')
I'm trying to write code that will disable submit button (or all submit buttons) on the page to avoid double postback.
I thought of generating my own postback javascript function (and inject postback javascript using GetPostbackEventReference
) but maybe there are some better ways to do this? Or maybe there is some other way to avoid double postbacks?
Update:
I also want to figure out the best place to call javascript, e.g. if I call following script in the onclick button handler then button's server click event won't be wired up.
$('input[type=submit]').attr('disabled', 'disabled')
Share
Improve this question
edited Nov 16, 2010 at 13:46
Andrew Bezzub
asked Nov 16, 2010 at 13:33
Andrew BezzubAndrew Bezzub
16k7 gold badges54 silver badges73 bronze badges
1
- See my answer for another question if you don't want to fix this on a button-by-button basis: stackoverflow./a/28844217/787757 – sparebytes Commented Mar 5, 2015 at 15:26
3 Answers
Reset to default 4http://greatwebguy./programming/dom/prevent-double-submit-with-jquery/
This should help you
1. $('form').submit(function(){
2. $(':submit', this).click(function() {
3. return false;
4. });
5. });
jQuery:
$('input[type=submit]').attr('disabled', 'disabled')
Otherwise, iterate through all document.getElementByTagName('input')
May be best to do this only for child nodes of the form that was submitted, though?
How about this:
$('input[type=button]').click(function() {
$('input[type=button]').each(function() {
$(this).attr('disabled', 'disabled')
});
});
Anytime any button is clicked, every button on the form bees disabled.
本文标签: javascriptBest way to disable all submit buttons after postbackStack Overflow
版权声明:本文标题:javascript - Best way to disable all submit buttons after postback - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745429540a2658265.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论