MoOx / pjax

Easily enable fast Ajax navigation on any website (using pushState + xhr)
MIT License
1.46k stars 125 forks source link

Issue when using loadUrl : Cannot read property 'requestOptions' #127

Closed onemoreahmad closed 6 years ago

onemoreahmad commented 6 years ago

Hi, I'm using this lib with webpack, and everything work just fine. But when I try to use loadUrl() I got an error.

var pjax = new Pjax({
    elements: "a:not(.no-pjax)", // default is "a[href], form[action]"
    selectors: ["#content-container"]
});

pjax.loadUrl("/");

I got this error

Uncaught TypeError: Cannot read property 'requestOptions' of undefined
    at Pjax.loadUrl (app.js?v=1.27:sourcemap:13514)

I don't know if this is a bug or I'm missing some thing. Thank you

onemoreahmad commented 6 years ago

With the help of the answer here https://github.com/MoOx/pjax/issues/32#issuecomment-59639530

I managed to get it working by doing so :

   pjax.options.requestOptions = {}
   pjax.loadUrl('/', $.extend({}, pjax.options) )

Thanks.