Skip to content

Commit 73ffcc5

Browse files
committed
Merge pull request #545 from slimsag/master
Add blurFocus option to disable bluring the focus of existing elements.
2 parents c70ffe2 + ebaf920 commit 73ffcc5

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

jquery.pjax.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -292,10 +292,15 @@ function pjax(options) {
292292
window.history.replaceState(pjax.state, container.title, container.url)
293293
}
294294

295+
// Only blur the focus if the focused element is within the container.
296+
var blurFocus = $.contains(options.container, document.activeElement)
297+
295298
// Clear out any focused controls before inserting new page contents.
296-
try {
297-
document.activeElement.blur()
298-
} catch (e) { }
299+
if (blurFocus) {
300+
try {
301+
document.activeElement.blur()
302+
} catch (e) { }
303+
}
299304

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

0 commit comments

Comments
 (0)