Skip to content

Title tag not updated #4

@ronheywood

Description

@ronheywood

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);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions