New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jquery-pjax is not compatible with jQuery 3.0.0 #634

Closed
WTVader opened this Issue Jun 19, 2016 · 26 comments

Comments

Projects
None yet
@WTVader
Copy link

WTVader commented Jun 19, 2016

When using the latest version of jquery (3.0.0) jQuery.event.props is undefined in pjax. See also jquery/api.jquery.com#405

@semiromid

This comment has been minimized.

Copy link

semiromid commented Jun 20, 2016

I also. Not working with jquery (3.0.0)

jquery.pjax-min.js:1 Uncaught TypeError: Cannot read property 'push' of undefined

@juanmendez92

This comment has been minimized.

Copy link

juanmendez92 commented Jun 25, 2016

It's true, I have the same problem with jQuery 3.0.0

@celsworth

This comment has been minimized.

@oh-ren

This comment has been minimized.

Copy link

oh-ren commented Jul 4, 2016

The event.props bit can be fixed by this (AFAICT):

if ( $.event.props && $.inArray('state', $.event.props) < 0 ) {
  $.event.props.push('state');
} else if ( ! ('state' in $.Event.prototype) ) {
  $.event.addProp('state');
}

https://github.com/defunkt/jquery-pjax/blob/master/jquery.pjax.js#L914

BUT the code also makes use of .context & .selector which are removed properties since jQuery 3.0 as well. I might try to make the plugin work for jQuery 3.0, but I guess the whole plugin is in need for a major overhaul...

@itwy

This comment has been minimized.

Copy link

itwy commented Jul 5, 2016

@oh-ren waiting for the remaining fixes :)

@oh-ren

This comment has been minimized.

Copy link

oh-ren commented Jul 6, 2016

Ok, I fabricated something.
Use at your own peril though (just came up with this, but things seem to work) ;-)

https://gist.github.com/oh-ren/7afed121c2cd29993bd26c996fc6f501

@itwy

This comment has been minimized.

Copy link

itwy commented Jul 6, 2016

Thank you so much @oh-ren, it works fine for me.

@WTVader

This comment has been minimized.

Copy link
Author

WTVader commented Jul 10, 2016

Good job oh-ren! Your modification works also fine for me. However, a major rework of pjax might be a good approach for the future.

@oh-ren

This comment has been minimized.

Copy link

oh-ren commented Jul 10, 2016

Thanks guys, I just made an issue (#638) regarding the future / maintenance status of the plugin.

@itwy

This comment has been minimized.

Copy link

itwy commented Jul 16, 2016

Unfortunately, in some instances, the fix does not replace the page content. Not sure why though but reverting to the jq 2 works as expected. No error messages :(

@oh-ren

This comment has been minimized.

Copy link

oh-ren commented Jul 16, 2016

Hmm... Not run into that yet myself (but not using it that intensively).
Let me/us know if you get an idea perhaps what might be the cause..
Is just reverting back to jQ2 sufficient, or do you also need to revert back to the original pjax?
(ps. what browser or you testing/running on?)

edit: do you recall if it perhaps only seems to happen when navigation through the browers's history vs. navigating via page links?

@itwy

This comment has been minimized.

Copy link

itwy commented Jul 16, 2016

Is just reverting back to jQ2 sufficient, or do you also need to revert back to the original pjax?

I switched both and it worked. No idea which anymore to be honest.

(ps. what browser or you testing/running on?)

Latest Chrome/Mac

do you recall if it perhaps only seems to happen when navigation through the browers's history vs. navigating via page links?

It happened when I clicked.

I actually wrestled with the issue for a few hours today until I gave up on pjax altogether and switched to Turbolinks. I suddenly felt I am wasting my time with an abandonware. Nonetheless, I greatly appreciate your help.

@oh-ren

This comment has been minimized.

Copy link

oh-ren commented Jul 17, 2016

I actually wrestled with the issue for a few hours today until I gave up on pjax altogether and switched to Turbolinks. I suddenly felt I am wasting my time with an abandonware. Nonetheless, I greatly appreciate your help.

Seems you are right..! Will check out Turbolinks myself (why haven't I heard of it before?) It seems it stems from the Rails world, am I right?

I did once, I guess when looking for pjax alternatives, stumble upon Intercooler, but for some reason didn't seem to come across Turbolinks.. Have you checked the former out as well perhaps?

Anyway, thanks for pointing it out!

@itwy

This comment has been minimized.

Copy link

itwy commented Jul 17, 2016

It seems it stems from the Rails world, am I right?

Yes, it was built by the small team at basecamp.com to avoid maintaining two codebases. It's nice to use it with Rails, it's not mandatory, I am using it with Django now and all I had to do is to write some JS and backend initialization to handle form submissions/redirections.

Also, Turbolinks comes official Android and iOS wrappers: https://www.youtube.com/watch?v=SWEts0rlezA

I haven't checked Intercooler but it looks like it requires writing an Intercooler applications with no option of removing it without severe refactoring which is not how pjax and Turbolinks are built.

@WTVader

This comment has been minimized.

Copy link
Author

WTVader commented Jul 22, 2016

I spent some hours to setup Turbolinks for my needs, but gave up after a while since Turbolinks replaces the current body element rather than a designated container. So I'll stick to pjax and hope a major rework will be available soon or later.

@markdavies

This comment has been minimized.

Copy link

markdavies commented Aug 10, 2016

I was initially put off by Turbolinks replacing the entire body. You can actually specify elements that are "permanent" though with the data-turbolinks-permanent parameter. Seems to be working well, so I'm moving over.

@WTVader

This comment has been minimized.

Copy link
Author

WTVader commented Aug 10, 2016

Well, but still the entire body element will be replaced with some exceptions. Not a feasible approach for my point of view. It's much better to select what should be replaced with an ajax call.

@itwy

This comment has been minimized.

Copy link

itwy commented Aug 10, 2016

Turbolinks replaces the current body element rather than a designated container.

I am loading these bits via some simple generic AJAX code. Definitely not doing a full reload when submitting forms, etc.

@mislav

This comment has been minimized.

Copy link
Collaborator

mislav commented Sep 8, 2016

@oh-ren Could you submit a pull request that restores jQ 3 compatibility?

@oh-ren

This comment has been minimized.

Copy link

oh-ren commented Sep 10, 2016

@mislav I consider my gist more or less a quick & dirty fix/workaround, so I didn't submit it as a PR on purpose.. Of course I still can do so if you want me to, I guess it would make it easy to review it that way anyway right?

@mislav

This comment has been minimized.

Copy link
Collaborator

mislav commented Sep 10, 2016

Benefits of a PR is that I can see a diff online, comment on it, and when merged, it records you as a contributor in git history.

@pencilcheck

This comment has been minimized.

Copy link

pencilcheck commented Oct 25, 2016

Looks like jquery-rails allows to include jquery2 specifically by changing from //= require jquery to //= require jquery2

@tm1000

This comment has been minimized.

Copy link

tm1000 commented Oct 28, 2016

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

@lydell

This comment has been minimized.

Copy link

lydell commented Nov 8, 2016

Another way to make this work with jquery 3.0 is to use jquery migrate

Except that the back and forward buttons won’t work unless you add an extra script: #638 (comment)

@mislav

This comment has been minimized.

Copy link
Collaborator

mislav commented May 19, 2017

jquery-pjax now works with jQuery versions 1.12 to 3.2: https://github.com/defunkt/jquery-pjax/releases/tag/v2.0.0

@lydell

This comment has been minimized.

Copy link

lydell commented May 20, 2017

@mislav Thanks! I upgraded to jquery-pjax 2.0.0 in my jQuery 3 project and removed jquery-migrate and everything seems to work! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment