Javascript Included Files Are Gone After AJAX Reload
I have a page in which I refresh a DIV by a JQUERY Ajax call, but I then lose al the javascript code that I included in the 'head' page. Do I need to include them twice? Looks to m
Solution 1:
Instead of using click
in your JS, you should use on
with class identifiers, as this will apply to elements added later via AJAX.
So instead of:
$("input[name$='vraag_afwijkende_prijzen']").click(function(){
if($(this).val() == 1){
$("#instructie_afw_prijzen_tekst").html(vraag4_ja);
$("#afwijkende_prijzen_vak").show('slow');
$("#afwijkend_1").show('slow');
}
//etc
Try something like:
$(document).on("click", ".vragen-radio", function() {
if ($(this).attr("name") == 'vraag_afwijkende_prijzen' && $(this).val() == 1) {
$("#instructie_afw_prijzen_tekst").html(vraag4_ja);
$("#afwijkende_prijzen_vak").show('slow');
$("#afwijkend_1").show('slow');
}
//etc
You can read about it in this question: Why use jQuery on() instead of click()
Post a Comment for "Javascript Included Files Are Gone After AJAX Reload"