Reputation: 1024
I've tried to add Pjax to a PHP site because I'd like to dynamically load content using ajax and pushState and Pjax seemed to be the best option.
In my site.js
file I have:
$(document).pjax('nav li a', '.wrap');
I've checked other answers and it seems that the JS isn't wrong and I was wondering if it was because I'm using PHP?
I've taken the jquery.pjax.js from the GitHub page although I get this error:
Uncaught TypeError: Object [object Object] has no method 'live'
In the <head>
I have:
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script src="/js/jquery.cookie.js"></script>
<script src="/js/jquery.pjax.js"></script>
<script>
$(function(){
// pjax
$('ul a').pjax('#main')
})
</script>
Upvotes: 0
Views: 1028
Reputation: 9858
jQuery.live() was deprecated in 1.7 and removed in 1.9.
As of jQuery 1.7, the .live() method is deprecated. Use .on() to attach event handlers. Users of older versions of jQuery should use .delegate() in preference to .live().
Use an older jQuery version or change your code, or the libraries code to use .on()
It looks like the latest version of pjax addresses this issue as well. See https://github.com/defunkt/jquery-pjax#legacy-api
Upvotes: 2
Reputation: 9244
PHP doens't have anything to with Pjax, it's only frontend feature to handle xhr request. For a good example, you can try to look at this demo page : http://pjax.heroku.com/, view source code and learn from it :)
Upvotes: 1