nie wiem dlaczego ale jak robie update ikonka przeładowania pojawia sie tylko na najwyrzym elemencie z formularz.
Formularz z bazy wyswietlam petlą:
Kod
<form id="aad-form2" action="" method="POST">
<?php foreach($myrows as $a): ?>
<input id="id" type="text" name="id" value="<?php echo $a->id; ?>">
<input id="name" type="text" name="name" value="<?php echo $a->name; ?>">
<input id="header" type="text" name="header" value="<?php echo $a->header; ?>">
<input id="body" type="text" name="body" value="<?php echo $a->body; ?>">
<input id="urls" type="text" name="urls" value="<?php echo $a->urls; ?>">
<input type="submit" name="aad-submit2" id="aad_submit2" class="button-primary" value="<?php _e('Update', 'aad'); ?>"/>
<img src="<?php echo admin_url('/images/wpspin_light.gif'); ?>" class="waiting" id="aad_loading2" style="display:none;"/>
<br />
<?php endforeach ?>
</form>
<?php foreach($myrows as $a): ?>
<input id="id" type="text" name="id" value="<?php echo $a->id; ?>">
<input id="name" type="text" name="name" value="<?php echo $a->name; ?>">
<input id="header" type="text" name="header" value="<?php echo $a->header; ?>">
<input id="body" type="text" name="body" value="<?php echo $a->body; ?>">
<input id="urls" type="text" name="urls" value="<?php echo $a->urls; ?>">
<input type="submit" name="aad-submit2" id="aad_submit2" class="button-primary" value="<?php _e('Update', 'aad'); ?>"/>
<img src="<?php echo admin_url('/images/wpspin_light.gif'); ?>" class="waiting" id="aad_loading2" style="display:none;"/>
<br />
<?php endforeach ?>
</form>
Sam update działa na każdym pojedynczym elemecie ale ikona ładowania pojawia sie tylko przy pierwszym elemecie:
Kod
<img src="<?php echo admin_url('/images/wpspin_light.gif'); ?>" class="waiting" id="aad_loading2" style="display:none;"/>
Tak wyglada kod jquery:
Kod
jQuery(document).ready(function($) {
$('#aad-form2').submit(function(){
//alert('test');
$('#aad_loading2').show();
$('#aad_submit2').attr('disabled', true);
data = {
action: 'aad_get_results2',
form_data: $('#aad-form2').serialize()
//aad_nonce: aad_vars.aad_nonce
};
$.post(ajaxurl, data, function (response) {
$('#aad_results2').html(response);
$('#aad_loading2').hide();
$('#aad_submit2').attr('disabled', false);
});
return false;
});
});
$('#aad-form2').submit(function(){
//alert('test');
$('#aad_loading2').show();
$('#aad_submit2').attr('disabled', true);
data = {
action: 'aad_get_results2',
form_data: $('#aad-form2').serialize()
//aad_nonce: aad_vars.aad_nonce
};
$.post(ajaxurl, data, function (response) {
$('#aad_results2').html(response);
$('#aad_loading2').hide();
$('#aad_submit2').attr('disabled', false);
});
return false;
});
});
Jak zrobic aby ta ikona pokazywała się przy każdym elemecie ktory jest klikniety? A nie przy pierwszym.
Sam update do bazy działa na kazdym z osobna.