Skip to content

Commit

Permalink
Merge pull request defunkt#545 from slimsag/master
Browse files Browse the repository at this point in the history
Add blurFocus option to disable bluring the focus of existing elements.
  • Loading branch information
mislav committed Jul 21, 2015
2 parents c70ffe2 + ebaf920 commit 73ffcc5
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions jquery.pjax.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,10 +292,15 @@ function pjax(options) {
window.history.replaceState(pjax.state, container.title, container.url)
}

// Only blur the focus if the focused element is within the container.
var blurFocus = $.contains(options.container, document.activeElement)

// Clear out any focused controls before inserting new page contents.
try {
document.activeElement.blur()
} catch (e) { }
if (blurFocus) {
try {
document.activeElement.blur()
} catch (e) { }
}

if (container.title) document.title = container.title

Expand Down

0 comments on commit 73ffcc5

Please sign in to comment.