PJAX-Standalone icon indicating copy to clipboard operation
PJAX-Standalone copied to clipboard

Update pjax-standalone.js

Open jameswragg opened this issue 10 years ago • 3 comments

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.

jameswragg avatar Oct 10 '14 10:10 jameswragg

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.

jameswragg avatar Oct 10 '14 11:10 jameswragg

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 :)

thybag avatar Oct 28 '14 22:10 thybag

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

jameswragg avatar Nov 11 '14 11:11 jameswragg