Open jameswragg opened 10 years ago
With hindsight, maybe pass the click event & options to beforeSend() and allow beforeSend to cancel the click/request. Use case: I provide a loading indicator (spinner) on a clicked pjax link and while the request is processing I want to prevent the user from clicking on more links, creating pjax requests to queue up.
Hello,
Sorry about the slow response, I've merged this change (Along with some others) in to the develop branch https://github.com/thybag/PJAX-Standalone/tree/develop
I'll hopefully be able to have a look at rolling to master once i find time to do some proper testing on it all :)
Hi, thanks for picking this up. Unfortunately I don't think my change is really the proper solution.
To explain: I need access to the clicked node in the beforeSend (all?) callback, but more importantly the beforeSend callback is currently a fired event rather than a function call that can potentially cancel the click event. I think this is a much more useful behaviour & follows the jQuery ajax model with their beforeSend event ( see http://api.jquery.com/jquery.ajax/ )
I'd revert the merge of this PR & I'll look to refactor if this is still a maintained project?
James
I was hoping a reference to the clicked node was available in beforeSend (I wanted to add a class to the link) so added it here. Available in the event passed to beforeSend as e.data.node.