English 中文(简体)
Jquery 调用父 div 来显示装载器
原标题:Jquery call a parent div to show loader
  • 时间:2012-05-24 16:27:22
  •  标签:
  • jquery
  • ajax

我有一连串的Divs和同级的Divs 来源于FORACHEG。每张都含有一张表格和一个使用jquery的ajax呼叫。

当对表格进行反射时,我只希望一个装载器出现在该div中,但用下面的例子来说明时,它会出现在所有它们中,或者根本不出现在它们中。 当然,我做错事了,但不确定是什么。我有:

$( .form-approve ).unbind( submit ).submit(function () {

        var item = $(this).parent( div );

        item.next( .loading ).show();

// etc. etc

我确定如何在递交表格的地方显示装载器内装的内装,请有人帮忙吗?

该页面包含以下 html :

 <?php foreach ($this->records as $r):?>
 <div class="requests">
 // show a name etc.
 <div class="log"> // this div is shown using a toggle
<form class="form-approve" etc.>
....
</form>
<div class="loader"></div>
</div>
<? endif; ?>

当然,在一页中多次重复上述内容。

问题回答

这项工作应当:

$( .form-approve ).unbind( submit ).submit(function () {
        $(this).next( div.loader ).show();
});

div 您想要显示的

是在窗体本身旁边, 所以 $( this. next( div.loader) 应该以它为适当目标, 不需要通过父目录检索它 。

编辑。只要确定您应该拥有每个窗体的代码,就像这样

$( .form-approve ).each(function() {
     $(this).unbind( submit ).submit(function () {
         $(this).next( div.loader ).show();
     });
}) 




相关问题
ajax login using httpRequest?

I am trying to develop my login script to give feedback to the user if the login is valid or not. Basically if it isn t correct a div box will show saying its wrong, if its correct it will show its ...

Virtual Tour using sketch up, ajax, flash technologies

I want to know if there are existing technology that make your 3d models in sketch into virtual tours, using either Ajax or Flash for web presentation. If there s none, which will be a good approach ...

How can i update div continuously

I have asp.net application where i have a div which showing the value from other site. The value of that site is changing continuously. I want that my div will automatically update in some interval ...