Pjax.switches not working? #68
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I installed Pjax with bower and tried to get your example with
switches: { ".js-Pjax": Pjax.switches.sideBySide }working but it fails in the browser with console error
undefined is not an object (evaluating 'Pjax.switches.sideBySide')It supposed to be fixed in 0.1.4. What version are you using?
Latest version pjax#0.2.3, tried with bower and also with npm.
And as I see it
Pjax.switches.sideBySideshould not be undefined, right?Yeah. It's defined here
b96b0f41a7/lib/switches.js (L18)I think I changed the API with 0.2.x.
Can you try instead to use
require("pjax/lib/switches.js").sideBySide?I'm currently using version 0.2.4 and getting the same error when trying to use sideBySide.
I tried changing to the code to your above recommendation but still no luck. Here's the standard pjax call from your demo code I am testing with:
` document.addEventListener("DOMContentLoaded", function () {
var pjax = new Pjax({
Which results in the following console.log error:
(index):165 Uncaught TypeError: Cannot read property 'sideBySide' of undefined
Fixed in the readme.md example #74 Try that it should work now.
Thanks.
After I implemented with
require("pjax/lib/switches.js").sideBySideI have an error on console that saysUncaught ReferenceError: require is not defined@wongsynee are you using webpack/browserify?
Thank you for the prompt reply. However, I'm not too familiar with either, do I browserify my custom js file or the entire pjax folder that I have downloaded with bower?
You will want to bundle up all your JS into one file, see below for example (old project)
`
Got it, thank you!