It would be nice if pjax supported History.js to solve those pesky cross-browser compatibility bugs and also optionally support HTML4 browsers.
What bugs? I'm interested but need more information.
We already have HTML4 support: https://github.com/defunkt/jquery-pjax/blob/master/jquery.pjax.js#L175-177
No worries. They're listed in the readme of History.js, here is the extract:
:) for the HTML4 support, History.js provides an optional hash fallback which still allows for data and titles (even replaceState) etc. While I agree that hashes aren't ideal, some people do enjoy them - hence why they're optional :)
Don't know if History.js is the lib of choice, but a crossbrowser (and non html5) fallback would be great for pjax...
I'm 👍 on this. I'd much rather see a hash in the url than suffer through the slowish page loads. Of course it means you also have to read the hash content on a page load, which is more work than when you just use pushState.
hi, I've written in the past something similar to pjax, and face this problem
The best solution I found is a jquery plugin to provide cross-browser hashchange event (in older browsers it uses polling):
We're not going to support browsers without pushState, but feel free to fork and roll your own ;)
@defunkt this isn't just about browsers without pushState but browsers with pushState. Using History.js will allow you to support Safari and iOS devices as well. Google Chrome will also fire a onpopstate event at the state, where Firefox 4 and Safari don't. Also the data param never persists if the browser session was closed. These are solved with History.js and you don't need to include the history.html4.js for HTML4 support if you don't want to. But if you do, then it will all work find and good too.
@defunkt, counter-argument? Does GitHub not actually care about the bugs between the browsers which actually do support the HTML5 History API? and/or providing the rich experience to HTML4 users too?
@balupton, counter-counter-argument: Falling back to URL fragments for HTML4 users breaks the Internet.
Or at least as long as you want all the old links pointing to your site to work.
Which should be forever.
👍 on working around cross-browser issues with HTML5 History API.
👎 on providing any sort of history support for HTML4 browsers.
okay.... so @defunkt you are for including History.js for working around cross-browser issues with HTML5 History API, and without the HTML4 support?....
pjax, as a design goal, is for browsers that support pushState. That's the p in pjax. I understand that some people want to target browsers which don't support pushState, but those people don't have to use pjax. Mostly I've been recommending History.js to anyone who wants something outside the scope of pjax, and I will continue doing that in the future.
As for browser bugs, pjax already has some fixes for buggy pushState implementations, and I'd be quite happy to merge/add more as they pop up. ⚡ I know there's one pending pull request (#30) with a fix I haven't yet tested and merged.
@bobthecow is really right. but i needed hash support, i added it. https://github.com/ckald/jquery-pjax/
@ckald: when I tried to use your merge of hashchange-event and pjax, I got this error in IE9 saying that .pjax is not a method. When I used the regular version of pjax, I did not get the error.
This is how I'm calling pjax (using jquery 1.7.1): $("a[href^='"+siteURL+"']:not([href='/wp-admin/']):not([href='/wp-login.php']):not([href$='/feed/'])").pjax("#primary");
@DogKnob as I remember, nobody didn't have problems with this. Leave an issue on https://github.com/ckald/jquery-pjax/ with a proof link please to continue discussion
@ckald: I did manage to get this working somewhat. I no longer get the error, but I'm having IE-specific issues with Wordpress now :(
@DogKnob Hey, i think defunkt doesn't wants us talking here not about his lib. Personally i won't flood here anymore. https://github.com/ckald/jquery-pjax
Just as a point of interest. I needed PJAX to work in IE9 specifically, so I simply included this https://github.com/devote/HTML5-History-API in the page. So far seems to be working a treat.
@kim3er sorry pjax isn't going to target IE9.
No interest in PJAX adding support for IE9, I believe you're entirely correct not to. My last comment was purely informational for people wanting provide backwards compatibility easily. Rich
kim3er: no pjax customization was needed? oO
No customisation, I just added the script in a conditional statement before PJAX.
<!--[if lte IE 9]>
It's not perfect (neither is PJAX), but it's pretty good.