English 中文(简体)
j 无限循环中的 j 查询动画
原标题:jQuery animate in infinite loop

我想让这一切成真:

  1. 防止提交器按钮提交窗体

  2. 淡出元素

  3. 然后提交表格,然后提交表格

却被无穷无尽的动画循环所困住!

HTML HTML

<form id="postitron" method="post" action="/postitron/answertron.php">
  <input type="hidden" name="acces" value"yes">
  <input id="submit" type="submit" value="DOIT">
</form>

JavaScript 贾斯克里普特

$( #postitron ).submit(function(e){
    e.preventDefault();
    $( #page ).animate({opacity:0},400, function(){
        $( #postitron ).submit();
    });
});

P. S. - 我还尝试了 . one () 方法, 而不是 .sumit () , 但它阻止在动画完成后在 # constantitron 上执行提交方法 : ()

最佳回答

这是因为您在 SUBMIT 上将事件绑定在 SUBMIT 上,而您的 .antimate回调功能 SUBMIT , 正在显示窗体... 导致无穷循环 。

< streng> 尝试一下:

submit 上的约束事件 .submit on , 绑定 . kick event on submit 按钮。

$( #submit ).click(function(e){
    e.preventDefault();
    $( #page ).animate({opacity:0},400, function(){
        $( #postitron ).submit();
    });
});

Bare 记住,我没有测试这个。

问题回答

sumit () calls your contern contimation submit 函数,该函数转而调用您的 submit submit 等。

尝试使用 DOM S 提交 :

$(#postitron) [0].submit()

您可以预先取消函数, 并在它内部, 解除了提交, 然后重新提交。 它是一个黑客, 但可能有效 。

或者你检查一下它是否隐藏起来 然后像这样重新提出来

var hidden = false;
$( #postitron ).submit(function(e){
    if ( !hidden ) {
        e.preventDefault();
        $( #page ).animate({opacity:0},400, function(){
            hidden = true;
            $( #postitron ).submit();
        });
    }
});




相关问题
images sliding continuously with <table> and jQuery

I m trying to write a little test page that circulates images through a window (see image). I have colored boxes inside a table (gray border), with each box being a element. <table id="boxes" ...

WPF 3d rotation animations

I have a few 3d rectangles on my screen that I want to pivot around the Y axis. I want to press down with the mouse, and rotate the 3d object to a max rotation, but when the user moves their mouse, ...

Disable Windows 7 touch animation in WPF

In Windows 7 when you touch the screen there is a short animation that occurs at the touch point. In my WPF app I want to display my own touch points, without showing the one supplied by Windows. ...

jQuery block moving

I wanna move a div block to the top, so I coded like this: CSS part: .movingPart{ margin-top:80px; } jQuery part: $(document).ready(function() { $( #btn ).click(function() { $( .movingPart )....

Direct 2D gnuplot PNG animation?

Can anyone please confirm that yes/no Gnuplot 4.5 (on CVS) can output 2D animated PNG files? I have numerous datasets but one line that I d like to show iteratively in 3 different places in my graph. ...

Visual State Manager VS Animations in WPF

There is a lot of talk about the simplicity of Visual States and the transitions between them in WPF/Silverlight. I have the need to generate animations dynamically at runtime, to animate the ...

Create a ImageIcon that is the mirror of another one

I ll like to know if there is a way to create a ImageIcon that is the mirror of another ImageIcon. Searching on Google, I found how to do it by using many AWT libraries. Is there a way to do it with ...

how to drag in the animation in iphone application?

Iphone application is using the static co-ordinates to reach at some points in the application,which is based on the button event. But what i want is when i drag the item than it should reach at some ...

热门标签