Hi - wonder if anyone could help me, I need to somehow access the anchor that was actually clicked to trigger the pjax:send event. I figured I could do this by listening for the click on any but this event happens after the pjax:send. Any ideas?
Hi - wonder if anyone could help me, I need to somehow access the anchor that was actually clicked to trigger the pjax:send event. I figured I could do this by listening for the click on any <a> but this event happens _after_ the pjax:send. Any ideas?
var pjax = new Pjax({
'elements': '.some-random-selector-with-no-matches'
});
$('.something').click(function(e) {
e.preventDefault();
var target = e.getCurrentTarget; // is what you want
pjax.loadUrl(url, options); // triggers pjax
});
Note that pjax has to be a singleton, or it may break history (I haven't tested it, but from code inspection it seems that pjax was designed to only be instantiated once). The simplest way to do this is to instantiate pjax with a no-match selector.
@howells I trigger pjax call directly.
```
var pjax = new Pjax({
'elements': '.some-random-selector-with-no-matches'
});
$('.something').click(function(e) {
e.preventDefault();
var target = e.getCurrentTarget; // is what you want
pjax.loadUrl(url, options); // triggers pjax
});
```
Note that pjax has to be a singleton, or it may break history (I haven't tested it, but from code inspection it seems that pjax was designed to only be instantiated once). The simplest way to do this is to instantiate pjax with a no-match selector.
Huh that's an interesting approach yeah - thanks. Right now I overrode Pjax.prototype.attachLink with the same function, but prepended it with various stuff that I needed to do, which isn't really sustainable!
Huh that's an interesting approach yeah - thanks. Right now I overrode `Pjax.prototype.attachLink` with the same function, but prepended it with various stuff that I needed to do, which isn't really sustainable!
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Hi - wonder if anyone could help me, I need to somehow access the anchor that was actually clicked to trigger the pjax:send event. I figured I could do this by listening for the click on any but this event happens after the pjax:send. Any ideas?
@howells I trigger pjax call directly.
Note that pjax has to be a singleton, or it may break history (I haven't tested it, but from code inspection it seems that pjax was designed to only be instantiated once). The simplest way to do this is to instantiate pjax with a no-match selector.
Huh that's an interesting approach yeah - thanks. Right now I overrode
Pjax.prototype.attachLinkwith the same function, but prepended it with various stuff that I needed to do, which isn't really sustainable!With #94, you can access the element that triggered the
pjax:sendevent withevent.triggerElement.