Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery monitoring form field created by AJAX query
    primarykey
    data
    text
    <p>Preface: I am sure this is incredibly simple, but I have searched this site &amp; the jQuery site and can't figure out the right search term to get an answer - please excuse my ignorance!</p> <p>I am adding additional form fields using jQuery's ajax function and need to then apply additional ajax functions to those fields but can't seem to get jQuery to monitor these on the fly form fields. </p> <p>How can I get jQuery to use these new fields?</p> <pre><code>$(document).ready(function() { $('#formField').hide(); $('.lnk').click(function() { var t = this.id; $('#formField').show(400); $('#form').load('loader.php?val=' + t); }); //This works fine if the field is already present var name = $('#name'); var email = $('#email'); $('#uid').keyup(function () { var t = this; if (this.value != this.lastValue) { if (this.timer) clearTimeout(this.timer); this.timer = setTimeout(function () { $.ajax({ url: 'loader.php', data: 'action=getUser&amp;uid=' + t.value, type: 'get', success: function (j) { va = j.split("|"); displayname = va[1]; mail = va[2]; name.val(displayname); email.val(mail); } }); }, 200); this.lastValue = this.value; } }); }); </code></pre> <p>So if the is present in the basic html page the function works, but if it arrives by the $.load function it doesn't - presumably because $(document).ready has already started.</p> <p>I did try:</p> <pre><code>$(document).ready(function() { $('#formField').hide(); $('.lnk').click(function() { var t = this.id; $('#formField').show(400); $('#form').load('loader.php?val=' + t); prepUid(); }); }); function prepUid(){ var name = $('#name'); var email = $('#email'); $('#uid').keyup(function () { snip........... </code></pre> <p>But it didn't seem to work...</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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