run scripts after pjax load #192

Closed
opened 2019-01-16 09:02:38 -05:00 by nicdnepr · 7 comments
nicdnepr commented 2019-01-16 09:02:38 -05:00 (Migrated from github.com)

why pjax not runs scripts after load page?
for example in page footer script alert
after pjax load alert not fired
if click f5 then alert fired

why pjax not runs scripts after load page? for example in page footer script alert after pjax load alert not fired if click f5 then alert fired
BehindTheMath commented 2019-01-16 09:10:07 -05:00 (Migrated from github.com)

Please post some code that shows the issue.

Please post some code that shows the issue.
nicdnepr commented 2019-01-16 13:39:05 -05:00 (Migrated from github.com)

here test code

<!doctype html>

<html lang="en">
<head>
  <meta charset="utf-8">

  <title>The HTML5 Herald</title>
  <meta name="description" content="The HTML5 Herald">
  <meta name="author" content="SitePoint">

  <script src="https://cdn.jsdelivr.net/npm/pjax/pjax.js"></script>


</head>

<body>
  
  <div id='content'>
      page 1
  <a href='2.html' ajaxLink>page 2</a>
  </div>
  <div id='footer'></div>
  
  <script>
  new Pjax({
  elements: 'a[ajaxLink]',
  selectors: ['#content'],
})
  </script>
</body>
</html>

2.html

<!doctype html>

<html lang="en">
<head>
  <meta charset="utf-8">

  <title>The HTML5 Herald</title>
  <meta name="description" content="The HTML5 Herald">
  <meta name="author" content="SitePoint">

  

</head>

<body>
  <div id='content'>page 2</div>
  <div id='footer'>
  <script>alert('load');</script>
  </div>
</body>
</html>

here test code ``` <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>The HTML5 Herald</title> <meta name="description" content="The HTML5 Herald"> <meta name="author" content="SitePoint"> <script src="https://cdn.jsdelivr.net/npm/pjax/pjax.js"></script> </head> <body> <div id='content'> page 1 <a href='2.html' ajaxLink>page 2</a> </div> <div id='footer'></div> <script> new Pjax({ elements: 'a[ajaxLink]', selectors: ['#content'], }) </script> </body> </html> ``` 2.html ``` <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>The HTML5 Herald</title> <meta name="description" content="The HTML5 Herald"> <meta name="author" content="SitePoint"> </head> <body> <div id='content'>page 2</div> <div id='footer'> <script>alert('load');</script> </div> </body> </html> ```
nicdnepr commented 2019-01-17 04:14:40 -05:00 (Migrated from github.com)

any ideas?

any ideas?
BehindTheMath commented 2019-02-12 21:32:27 -05:00 (Migrated from github.com)

I don't see any issues with the above code. The alert shows for me after clicking the link.

I don't see any issues with the above code. The alert shows for me after clicking the link.
BigGitWorld commented 2020-11-18 08:38:06 -05:00 (Migrated from github.com)

@BehindTheMath
I run the above code but the alert did not called!
How did you run it with alert?

@BehindTheMath I run the above code but the alert did not called! How did you run it with alert?
BehindTheMath commented 2020-11-18 08:44:52 -05:00 (Migrated from github.com)

I'm sorry, but I can no longer help with this. This issue is from almost 2 years ago, and I haven't used this library in almost that long.

I'm sorry, but I can no longer help with this. This issue is from almost 2 years ago, and I haven't used this library in almost that long.
BigGitWorld commented 2020-11-18 08:48:54 -05:00 (Migrated from github.com)

Your welcome.
Please can you tell me what version you have used?
I have serious problems with the latest version. I want to use it in my SPA project but <script> tags are not called. while I see in the ajx (xhr) response, I have <script> tags.
I opened a new issue but nobody help me and I don't know how do I have to solve it :(

Your welcome. Please can you tell me what version you have used? I have serious problems with the latest version. I want to use it in my SPA project but <script> tags are not called. while I see in the ajx (xhr) response, I have <script> tags. I opened a new issue but nobody help me and I don't know how do I have to solve it :(
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: iLoveElysia/pjax#192