Comments (4)
Having the same problem. No javascript from the page called by pjax is executed.
Is this the expected behavior or a bug?
from jquery-pjax.
I'm pretty sure it's a bug with jquery/browsers... from what I've seen theres not much they can do about it. When jquery parses a html fragment that includes it won't run any scripts in it. You can't replace() out them in the success block either - it's already too late.
The only solution seems to be to move per-page scripts into a global handler that checks the location.url and executes the code for the page when it sees that url is the current one.... then you could call that function in your pjax success handler.
To make things even more fun, there's no way for the pjax success handler to be called on a "back button" trigger, though I've seen references to a global success function that might work that I can't find anywhere.
from jquery-pjax.
What worked for me was to place my jQuery code in a function, call it normally on document.ready
(for non-pushState browsers), and then bind the function to pjax:end
, i.e.:
$('body').bind 'pjax:end', mainFunction
from jquery-pjax.
We basically need to move everything to events.
See #29
from jquery-pjax.
Related Issues (20)
- Multiple fragment processed
- Document links dump bytes in dom
- the current node list is empty
- PJAX memory Leak issue HOT 1
- Link to do just as browser back button HOT 2
- Prevent form submit with pjax when "enter" is clicked in a form element
- In the JavaScript code, Chinese is converted to unicode.
- the documented `ready pjax:end` does not work with Jquery 3.4.1 or 2.2.4 HOT 5
- How to cancel/abort ongoing request?
- Can't run a container cleanup before the cache snapshot
- When using Pjax, the target page is returned without replace the container
- Modal bootstrap is create class modal-backdrop two times when using pjax
- skeleton loading
- Unusual reaction with pjax (Content is duplciating) HOT 1
- New generation Pjax variations HOT 3
- Pjax switch fail: DOM doesn't look the same on new page
- The css class is missed,when i use PJAX,How to reload it?
- Wrong events lifecycle in case when ajax request is not async
- page reload after append link to hmtl
- 给a标签同时添加多个点击事件不生效
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jquery-pjax.