Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Set page title from fragment's `title` or `data-title` attribute.

  • Loading branch information...
commit 7d9841eb499d51959d6ef65397cd90b870bbd398 1 parent 7bf9047
@hellp hellp authored defunkt committed
Showing with 8 additions and 0 deletions.
  1. +3 −0  README.md
  2. +5 −0 jquery.pjax.js
View
3  README.md
@@ -163,6 +163,9 @@ Asp.Net MVC3: <http://biasecurities.com/blog/2011/using-pjax-with-asp-net-mvc3/>
Your HTML should also include a `<title>` tag if you want page titles to work.
+When using a page fragment, pjax will check the fragment DOM element
+for a `title` or `data-title` attribute and use any value it finds.
+
## events
View
5 jquery.pjax.js
@@ -120,6 +120,11 @@ var pjax = $.pjax = function( options ) {
title = $.trim( this.find('title').remove().text() )
if ( title ) document.title = title
+ // No <title>? Fragment? Look for data-title and title attributes.
+ if ( !title && options.fragment ) {
+ title = $fragment.attr('title') || $fragment.data('title')
+ }
+
var state = {
pjax: options.container,
fragment: options.fragment,
Please sign in to comment.
Something went wrong with that request. Please try again.