defunkt / jquery-pjax

pushState + ajax = pjax
https://pjax.herokuapp.com
MIT License
16.73k stars 1.97k forks source link

Bypassing event handler on "command + click" #687

Open iplanwebsites opened 7 years ago

iplanwebsites commented 7 years ago

Users use the keyboard shortcut to open links in new tabs. Pjax seems to break this browser behaviour.

staabm commented 7 years ago

Pjax on its own does not detect new windows. You should do this kind of check in your pjax integration code

iplanwebsites commented 7 years ago

I'm afraid this isn't possible. Let me clarify the problem. The click event handler assigned to my links need to be bypassed only when the command or ctrl is pressed on click.

if(e.ctrlKey || e.metaKey){
  //exit pjax, let the browser default behavior function (open the link in a new tab)
}
iplanwebsites commented 7 years ago

Here's the fix. Tested on OSX, should work on PC too. https://github.com/defunkt/jquery-pjax/pull/688