Note that there are some explanatory texts on larger screens.

plurals
  1. POAjax spinner on multiple inputs in same form
    primarykey
    data
    text
    <p>I have a spinner that displays when an ajax request is made using jquery:</p> <pre><code>$(document).bind("ajaxStart", function() { $('#myloader').show(); }); $(document).bind("ajaxStop", function() { $('#myloader').delay(1000).fadeOut('fast'); }); </code></pre> <p>The request is actually made on keyup in this case, I'm trying to work out how to use this spinner on multiple fields, so the spinner would display next to each field.</p> <p>Placing the spinner image isn't the problem, but connecting the the image to each field is what i'm finding difficult. If that makes sense?</p> <p>--UPDATE--</p> <p>The answers are very helpfull but I dont think its what im looking for.</p> <p>I have the following code:</p> <pre><code>&lt;div class="form_element"&gt; &lt;%= f.label :email, :class=&gt;"field_hint", :title=&gt;"Email" %&gt; &lt;%= f.text_field :email %&gt; &lt;div class="myloader" style="display:none;"&gt; &lt;p&gt; validating... &lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="form_element"&gt; &lt;%= f.label :username, :class=&gt;"field_hint", :title=&gt;"Username" %&gt; &lt;%= f.text_field :username %&gt; &lt;div class="myloader" style="display:none;"&gt; &lt;p&gt; validating... &lt;/p&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>Both of these fields have a keyup that does a remote call. I have changed the code slightly:</p> <pre><code>$('.form_element').ajaxStart(function() { $(this).children('.myloader').show(); }); $('.form_element').ajaxStop(function() { $(this).children('.myloader').delay(1000).fadeOut('fast'); }); </code></pre> <p>At the moment when an the ajax happens both spinners appear, I am trying to work out how to make each spinner div relevant to its field.</p> <p>I am new to Ajax so any advice on maybe doing the ajaxStart/Stop differently are more than welcome.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload