Closed oh-ren closed 7 years ago
I come across this one recently: https://github.com/falsandtru/pjax-api – if anyone has played with it?
I use pjax in production, so I'm interested in this library surviving. But I'm a terrible js dev, so I'm not sure I would be useful. It would be nice to at least get a comment from the current maintainers.
@oh-ren just take it over. Else our company may do that - this library is in need of a number of updates.
Sorry for the late reply; I was on vacation.
You're right to have noticed that pjax is unmaintained right now. The main reason why I mantained pjax last was that we are using it at GitHub in production. Lately, we “forked” pjax internally to switch it over to some new mechanisms that we're using in our JS code overall. Unfortunately, our edited pjax implementation isn't available to be open-sourced since it depends on some domain-specific details of our codebase.
I would like to help bring jquery-pjax to a state where it can stay used without much maintenance. The biggest blocker right now to future use seems to be jQuery 3.0 incompatibility. Apart from that, what other issues would block you from using this library in the year to come? Let's identify what those issues are and see if we can fix them. I could make a new release with those fixes.
However, while jquery-pjax is in hibernation mode, it won't receive substantial feature changes.
I recently integrated pjax into an application and used it in conjunction with a handy little async loader and the results were exceptional. It solved most issues in terms of initializing page specific components and assets, they seemed to work hand-in-hand, maybe something to consider?
For anyone curious about this, my application used partial views. Inside my layout view, I added the Loadjs component in the<head>
and pjax before the closing </body>
tag as we all commonly do. Within the#pjax-container
of each page I would use loadjs
to initialise this page specific components to load in asynchronously and it was a fucking sweet combination.
It would be interesting to hear what suggestions people have regarding the future of pjax, because it has extreme potential and growing strongly still. As an avid user of this particular component I would like to see a more slimmed down standalone version that doesn't require jQuery.
I would like to see a more slimmed down standalone version that doesn't require jQuery.
Me too. But, if we released such a thing, we would still need to code up a compatibility layer on top of that that restores the functionality of current jquery-pjax, so people can upgrade seamlessly.
@mislav is not worth integrating both a standalone and jQuery dependant version? As I mentioned earlier, a lot of plugin related issues were solved cooking in load.js for me. Maybe bringing in a third-party component, like they did with Typeahead and bloodhound and re-working only the main essential functions?
Another way to make this work with jquery 3.0 is to use jquery migrate: https://code.jquery.com/jquery-migrate-3.0.0.js
@tm1000 Thanks, you just saved my day! jQuery 2’s non-standard Promises drove me insane. Installed jQuery 3 and jquery-migrate – and it all worked! Yay! :)
Unfortunately, today I found that when pressing the back button in the browser, only the URL in the location bar changes, while the pjax container stays unchanged.
I found that jquery-pjax needs .selector
and .context
on jQuery objects, both of which do not exist in jQuery 3.
I managed to fix the problem by adding my own little extra jquery migrate script:
// jquery-pjax needs `.selector` and `.context` on jQuery objects, both of which
// do not exist in jQuery 3. This file adds them back.
//
// Adapted from from the deletions in this commit (for the file `src/core.js`):
// https://github.com/jquery/jquery-migrate/commit/f26c2930a66d088fb0c4d23a114d1561ed60d744#diff-7eb52b366866677666470e019283c8ea
var originalInit = jQuery.fn.init
jQuery.fn.init = function (selector, context) {
var ret = originalInit.apply(this, arguments)
if (selector && selector.selector !== undefined) {
ret.selector = selector.selector
ret.context = selector.context
} else {
ret.selector = typeof selector === 'string' ? selector : ''
if (selector) {
ret.context = selector.nodeType ? selector : context || document
}
}
return ret
}
jQuery.fn.init.prototype = jQuery.fn
So, for now, jquery@3 + jquery-migrate@3 + jquery-pjax@1 + the above script seems to work.
per source at https://code.jquery.com/jquery-migrate-1.4.1.js the hack you mentioned should not be necessary, as jquery-migrate should provide those properties.
see
// Fill in selector and context properties so .live() works
if ( selector && selector.selector !== undefined ) {
// A jQuery object, copy its properties
ret.selector = selector.selector;
ret.context = selector.context;
} else {
ret.selector = typeof selector === "string" ? selector : "";
if ( selector ) {
ret.context = selector.nodeType? selector : context || document;
}
}
As mentioned, I use jquery-migrate 3 (3.0.0 to be precise), not 1.4.1, which is also the version @tm1000 linked to. jquery-migrate has removed the .selector
and .context
(see the commit I mentioned in the code snippet in my last comment). I haven’t really used these jquery-migrate scripts before. Shouldn’t I use jquery-migrate 3 when I have jquery 3?
jquery-pjax is now fully compatible with jQuery 3.x: https://github.com/defunkt/jquery-pjax/releases/tag/v2.0.0
jquery-pjax seems unmaintained for a while now. I guess it would be cool if one of the (recent) maintainers (@mislav?) good give an update on the situation.
I recently did a hack so it can run with jQuery 3.x: https://github.com/defunkt/jquery-pjax/issues/634#issuecomment-230832497
I might do a (proper) fork, but doubting if I'm the right guy to maintain it (+ willing to).