0

I have seen other questions like this one here but they didn't seem to help.

I have purchased an html theme that changes/transitions between pages with ajax.

When I slide into a certain page where I am trying to use jQuery, nothing happens. But if I refresh that page then the jQuery fires.

Is there a way to get the jquery to work when transitioning into the page instead of having to refresh it?

Iggy's Pop
  • 589
  • 1
  • 6
  • 24
  • can you elaborate more on what exactly you're trying to achieve and show some codes? – yqlim Jul 07 '17 at 18:07
  • Sounds like an issue with dynamically created elements that do not exist within the DOM. – Adam Jul 07 '17 at 18:08
  • 1
    Do you have an example? Code "works" in that it does exactly what it's told to do. What is this code being told to do? What isn't it doing? "How do I get jQuery to work" isn't an answerable question. It *is* working, it just sounds like you want it to do something other than what it's written to do. Provide a specific example of the problem. – David Jul 07 '17 at 18:09
  • @AdamA, do you know how to overcome this? – Iggy's Pop Jul 07 '17 at 18:09
  • @David, at this point I am just trying to console.log a message: `$(document).ready(function(){ console.log("working"); });` – Iggy's Pop Jul 07 '17 at 18:09
  • So the JavaScript itself is being loaded into the page dynamically and not executing? Perhaps this would be helpful?: https://stackoverflow.com/questions/75943/how-do-you-execute-a-dynamically-loaded-javascript-block – David Jul 07 '17 at 18:13
  • Would it help if I gave you a link to the theme so you can see what it does? – Iggy's Pop Jul 07 '17 at 18:16

1 Answers1

0

I'm not sure how your template is set up but move jQuery to whatever the base file is that loads other libraries. It should be where all the CSS, etc, is loaded also.

Difster
  • 3,264
  • 2
  • 22
  • 32
  • I managed to get it to work like this: `$(document).on('click', "#submit", function () {` but I can only submit the form once. If there are validation errors and I try again, nothing happens – Iggy's Pop Jul 08 '17 at 11:20
  • Try putting that in another question with code examples. – Difster Jul 08 '17 at 17:18