Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Title tag not updated #4

Open
ronheywood opened this issue Apr 28, 2012 · 1 comment
Open

Title tag not updated #4

ronheywood opened this issue Apr 28, 2012 · 1 comment

Comments

@ronheywood
Copy link

The title tag is not updated - (FF12, and Chrome)

I don't know how to make a patch but for a fix - my git diff looks like this

@@ -258,6 +258,9 @@
     options.context = $container

     options.success = function(data, textStatus, jqXHR){
+        
+      var $data = $(data);
+      
       if ( options.fragment ) {
         // If they specified a fragment, look for it in the response
         // and pull it out.
@@ -275,11 +278,14 @@

       // Make it happen.
       this.html(data);
-
+    
       // If there's a <title> tag in the response, use it as
       // the page's title.
-      var oldTitle = document.title,
-      title = $.trim( this.find('title').remove().text() );
+      var oldTitle = document.title;
+      
+      title= findAll($data, 'title').last().text()
+      //title = $.trim( data.find('title').remove().text() );
+      
       if ( title ) document.title = title;

       var state = {
@@ -363,6 +369,24 @@
     return pjax.xhr;
   }

+    // Internal: Filter and find all elements matching the selector.
+    //
+    // Where $.fn.find only matches descendants, findAll will test all the
+    // top level elements in the jQuery object as well.
+    //
+    // elems - jQuery object of Elements
+    // selector - String selector to match
+    //
+    // Returns a jQuery object.
+    function findAll(elems, selector) {
+      var results = $()
+      elems.each(function() {
+        if ($(this).is(selector))
+          results = results.add(this)
+        results = results.add(selector, this)
+      })
+      return results
+    }

   pjax.defaults = {
     timeout: 650,
@@ -468,4 +492,5 @@
     $(window).hashchange();
   }

+
 })(jQuery);
@0x0h
Copy link

0x0h commented Jul 7, 2012

$("#content").bind('success.pjax',function() {
$('title').text("Title true");
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants