javascript - Select all not working after ajax load -
i using ajax load form fields. when select school, grade fields load. when select grade, show name check box appears. when select box appears, have click select box twice work. checkboxes not apart of dom until second click. not sure issue is.
here of code.
showname.html
<input type="checkbox" class="coursereportcheckall" onchange="thirdcheck();" id="checkall" name="coursereportcheckall">select all<br> <input type="checkbox" onchange="fourthcheck(this.selectedindex);" value="10" class="tid" id="tid" name="tid"> george washington<br> <input type="checkbox" onchange="fourthcheck(this.selectedindex);" value="11" class="tid" id="tid" name="tid"> john adams<br>
showcourse.html
<input type="checkbox" id="checkallcourse">select all<br /> <input type="checkbox" name="cid" id="cid" class="cid" value="12"/> twelve<br /> <input type="checkbox" name="cid" id="cid" class="cid" value="13"/> thirteen<br /> <input type="checkbox" name="cid" id="cid" class="cid" value="14"/> fourteen<br />
you want move jquery "on" outside of thirdcheck function. should set on jquery loaded, not when clicking on checkbox.
$(document).on('click', '.#checkall', function(event) ...
your problem click handler being set first time click , being executed second time click.
also, don't need include "." in front of '.#checkall'.
Comments
Post a Comment