1

i have a problem with my javascript on a pagination page (ajax). The first page is working well, but if i click on the "page 2" the javascript is not loading.

Here is a snipped of my js code which i add into the footer.php :

 jQuery(document).ready(function($){

        $('#mp-id-2130725945 div[data-label="Yes"] .mp-choice-label').click(function() {...}
 }

do I have to use a special code for pagination pages? I thought that the js will be reloaded?

thanks!

Aᴍɪʀ
  • 7,623
  • 3
  • 38
  • 52
Matthias M
  • 135
  • 3
  • 19
  • Try showing **all** relevant code. – GROVER. Jan 26 '17 at 16:42
  • Best guess: [Event binding on dynamically created elements?](http://stackoverflow.com/questions/203198/event-binding-on-dynamically-created-elements) – JJJ Jan 26 '17 at 16:43
  • And no, if the pagination works with Ajax, it won't reload scripts. – JJJ Jan 26 '17 at 16:44
  • thanks JJJ, i tried it with this code but i make something wrong. Possible that you quickly check this? jQuery(document).ready(function($){ $('#mp-id-2130725945 div[data-label="Yes"] .mp-choice-label').on('click', '#mp-id-2130725945 div[data-label="Yes"] .mp-choice-label', function(){ $("#mp-id-3372138702").css("display","block"); }); – Matthias M Jan 26 '17 at 16:59
  • It's supposed to be `$(document).on('click','#mp-id-2130725945 div[data-label="Yes"] .mp-choice-label')`. Repeating the selector isn't going to work. – JJJ Jan 26 '17 at 17:19
  • thanks! Question: do i add this into the document.ready function? jQuery(document).ready(function($){ $(document).on('click','#mp-id-2130725945 div[data-label="Yes"] .mp-choice-label'){ $("#mp-id-7740120141").css("display","block"); }; $('#mp-id-5597852198 div[data-label="Yes"] .mp-choice-label').click(function() { $("#mp-id-9153215455").css("display","block"); }); – Matthias M Jan 27 '17 at 10:15

0 Answers0