Page does not catch JS files later

Asked

Viewed 51 times

0

I’m having a problem, I looked on the Internet and did not find, I saw that there is a similar question here in Stack, but that did not solve my problem.

The thing is, I have several JS files, like for example one of "Show More", where he searches for more news, he picks up these upcoming news from another file that is the search.php, now what happens is this, some news has galleries that use JS, on the main page picks up correctly, but when I click Show More it shows the news but when I click to see the gallery does not work, to work I have to include that same JS in this page search.php, but it turns out that the page is a bit heavy, because it will have 2 equal JS that do the same function. Is that normal? JS does not take later files?

NOTE: I did not put the code here, because it is very large.

  • Put some part that you find interesting to show and pass the rest on the Pastebin.

  • You have already tried to isolate the function or method that initializes the galleries to just run it again after loading.php.php?

  • What do you mean? Isolate? I want it to work normally, but when you call fetch, it also works. That’s all

  • You commented that you need to include javascript again to create the galleries. You could create a function to create these galleries that you just re-run, without having to include javascript again. Similar to the way Facebook renders like, share and comments components

  • How would I create this function? The galleries were just one example...

1 answer

0

Guys, I’ve been racking my brain about this for days, and I didn’t think so, and the solution was pretty simple, so here’s who’s got this problem:

$('body'). on('click', 'like', Function() {

Just put the $('body'). because there it puts on the back page the function

Browser other questions tagged

You are not signed in. Login or sign up in order to post.