Closed JonDum closed 10 years ago
Hello,
Just to update on this, for now I'd rather stay with the current events model, just for backwards compatibility, although I do see the benefits in being able to set true callbacks. When i get time I'll have a more through look as i expect this is probably something that would be possible to configure via an option.
Thanks, Carl
Hello,
I've just pushed a change in to the develop branch which may solve your issue. https://github.com/thybag/PJAX-Standalone/tree/develop
The event object, accessible within the beforeSend, complete callbacks should now contain an additional attribute called "data" holding the PJAX settings at the time the event was fired (including among other things the loaded url)
pjax.connect({
'container': 'content',
'success': function(event){
var url = (typeof event.data !== 'undefined') ? event.data.url : '';
console.log("Sucessfully loaded "+ url);
}
});
Cool. That works fine.
I found myself wanting to load a specific script with requirejs for certain pages, but I couldn't do this before because pjax wouldn't pass the url that was clicked into the event callbacks.
Now, you can do this just by using
beforeSend
orcomplete
or whatever because it will pass the url into these callbacks.