The bottom line is that the functions applied to the DOM after the upgrade are not valid, since all the elements are updated and the old events to them are erased. One solution is to reload all functions again after each loading "form.html".
How to do it? There is one easy solution: write all the necessary code into a separate function and call it every time. Example:
function func() { $('.button0').click(function() { alert('ΠΠ°ΠΆΠ°Π»ΠΎΡΡ'); }); }; $(function() { func(); $('.button1').click(function() { $('.but').html('<button class="button0">ΠΠ±Π½ΠΎΠ²Π»Π΅Π½Π½Π°Ρ ΠΊΠ½ΠΎΠΏΠΊΠ°</button>'); func(); }); });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <p class="but"><button class="button0">ΠΠ°ΠΆΠΌΠΈ Π½Π° ΠΌΠ΅Π½Ρ</button></p> <button class="button1">ΠΠ±Π½ΠΎΠ²ΠΈΡΡ</button>
But in general for events of pressing, guidance, global events can be used, but in your case this is not appropriate. Example:
$(function() { $(document).on('click', '.button0', function() { alert('ΠΠ°ΠΆΠ°Π»ΠΎΡΡ'); }); $('.button1').click(function() { $('.but').html('<button class="button0">ΠΠ±Π½ΠΎΠ²Π»Π΅Π½Π½Π°Ρ ΠΊΠ½ΠΎΠΏΠΊΠ°</button>'); }); });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <p class="but"><button class="button0">ΠΠ°ΠΆΠΌΠΈ Π½Π° ΠΌΠ΅Π½Ρ</button></p> <button class="button1">ΠΠ±Π½ΠΎΠ²ΠΈΡΡ</button>