Skip to content

Commit b0b0885

Browse files
committed
Add pjax:clicked event
Fires after pjax:click and after the pjax request is initiated
1 parent 9930024 commit b0b0885

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

jquery.pjax.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ function handleClick(event, container, options) {
9595
if (!clickEvent.isDefaultPrevented()) {
9696
pjax(opts)
9797
event.preventDefault()
98+
99+
clickEvent = $.Event('pjax:clicked')
100+
$(link).trigger(clickEvent, [opts])
98101
}
99102
}
100103

test/unit/fn_pjax.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,4 +217,17 @@ if ($.support.pjax) {
217217

218218
frame.$("a[href='/dinosaurs.html']").click()
219219
})
220+
221+
asyncTest("triggers pjax:clicked event from link", function() {
222+
var frame = this.frame
223+
224+
frame.$("#main").pjax("a").on("pjax:clicked", function(event, options) {
225+
ok(event)
226+
ok(options.container.is('#main'))
227+
ok(options.url.match("/dinosaurs.html"))
228+
start()
229+
})
230+
231+
frame.$("a[href='/dinosaurs.html']").click()
232+
})
220233
}

0 commit comments

Comments
 (0)