Pass the element that triggered Pjax to the pjax:send event #94

Merged
BehindTheMath merged 1 commits from enhancement/pass-element-triggered into master 2017-12-21 13:06:50 -05:00
BehindTheMath commented 2017-12-21 00:19:16 -05:00 (Migrated from github.com)

Closes #62.

With this PR, you can access the element that triggered the pjax:send event with event.triggerElement.

Closes #62. With this PR, you can access the element that triggered the `pjax:send` event with `event.triggerElement`.
MoOx (Migrated from github.com) approved these changes 2017-12-21 01:35:16 -05:00
ldrummond commented 2020-05-20 13:19:29 -05:00 (Migrated from github.com)

Fair warning if you end up here - be careful listening to pjax events with Jquery "on". It appears to overwrite the custom pjax event and leaves triggerElement undefined. Probably should be pretty obvious but it took me a while to figure out.

$(document).on("pjax:send", function(e) { console.log(e.triggerElement) // undefined })

Is this worth mentioning in the docs?

Fair warning if you end up here - be careful listening to pjax events with Jquery "on". It appears to overwrite the custom pjax event and leaves triggerElement undefined. Probably should be pretty obvious but it took me a while to figure out. `$(document).on("pjax:send", function(e) { console.log(e.triggerElement) // undefined })` Is this worth mentioning in the docs?
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: iLoveElysia/pjax#94