Skip to content

Commit

Permalink
Merge pull request #345 from defunkt/did-click-event
Browse files Browse the repository at this point in the history
Add pjax:clicked event
  • Loading branch information
josh committed Jan 29, 2014
2 parents 9930024 + b86fd5a commit 867b23a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions jquery.pjax.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ function handleClick(event, container, options) {
if (!clickEvent.isDefaultPrevented()) {
pjax(opts)
event.preventDefault()
$(link).trigger('pjax:clicked', [opts])
}
}

Expand Down
13 changes: 13 additions & 0 deletions test/unit/fn_pjax.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,4 +217,17 @@ if ($.support.pjax) {

frame.$("a[href='/dinosaurs.html']").click()
})

asyncTest("triggers pjax:clicked event from link", function() {
var frame = this.frame

frame.$("#main").pjax("a").on("pjax:clicked", function(event, options) {
ok(event)
ok(options.container.is('#main'))
ok(options.url.match("/dinosaurs.html"))
start()
})

frame.$("a[href='/dinosaurs.html']").click()
})
}

0 comments on commit 867b23a

Please sign in to comment.