English 中文(简体)
如何防止 jQuery BlubUI 触发
原标题:How to prevent jQuery BlockUI from triggering

我做了""http://jsfiddle.net/BXVDU/"rel="nofollow">jQueryBlockUI Plugin , 在每个提交行动表上触发:

$("form").submit(function() {
    jQuery.blockUI();
});

我想在提交一些表格之前先确认其中的一些表格:

<form method="POST" onSubmit="return(confirm( Really submit? ));">

When I hit "Cancel" on the confirm popup box, the BlockUI gets triggered and blocks the interface. It never gets unblocked.
Here s an example: http://jsfiddle.net/8B8yA/.

问题是如何防止BlucUI在按下“ 取消” 时被触发 。

我曾尝试在“取消”动作中添加 $.unblockUI () :

if(!confirm("Really submit?")) {
    $.unblockUI();
    return(false);
}

但显然行不通,因为在采取 " 解除障碍行动 " 之前就要求采取 " 解除障碍行动 " 。

最佳回答

怎么样:

$("form").submit(function() {
    if(!$(this).hasClass( skip ))
    jQuery.blockUI();
});​

<html>
  <head>
    <script src="http://malsup.github.com/jquery.blockUI.js">
    </script>
  </head>
  <body>
    <form method="POST" onSubmit="return (function(form) { var c = confirm( Are you sure? ); if(!c) { $(form).addClass( skip ); } return c; })(this);">
      <input type="submit">
    </form>
  </body>
<html>​

见:http://jsfiddle.net/8B8yA/5

问题回答

您可以尝试将 < strong > submit 从窗体和行为中删除 :

$("form").submit(function() {
    if(confirm( Really submit? )) {
        jQuery.blockUI();
    }
    else {
        return;
    }
});

你的意思是这样的:jsFiddle

您可以在表格中添加需要块 ui 的id, 例如 :

$("#yourFormId").submit(function() {
        if(confirm( Really submit? )) {
            jQuery.blockUI();
        }
        else {
            return;
        }
    });




相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签