2016-04-07 4 views
0

Ich versuche, das JQuery Table Sorter-Plugin zu verwenden, aber ich erhalte Fehler, wenn ich versuche, die Tabelle zu sortieren.jQuery TableSorter Plugin Fehler: kann Eigenschaft '1' von undefined nicht lesen

Dies ist die Fehlermeldung:

cannot read property '1' of undefined 

Das ist mein HTML-Code:

<table id='tweetResult' class="tablesorter" style="width:500px;"> 
<thead> 
    <th>Photo</th> 
    <th>Name</> 
    <th>Status</th> 
    <th>Place Name</th> 
    <th>Coordinate</th> 
    <th>Created At</th> 
    </thead> 
    <tbody> 

    </tbody> 
</table> 

Der tbody Inhalt in js Format:

$(document).ready(function(){ 
    $("#tweetResult").tablesorter(); 
}); 

(function(){ 
    var location = new Array(); 
    var query = '%23CM0655'; 
    var url = "search.php"; 
    $.post(url, {query:query}, function(tweets){ 
     console.log(tweets); 
     $("#tweetResult tbody").html(""); 
     var geoEnabled = false; 
     var placeName = ""; 
     var countryName = ""; 

     for(var i=0; i<tweets.statuses.length; i++){ 
      var row = $("<tr></tr>"); 
      var img = $("<td><img src='" + tweets.statuses[i].user.profile_image_url + "' class='tweetpic'/></td>"); 
      row.append(img); 
       // row.append($("<td></td>").html(tweets.statuses[i].user.screen_name)); 

      row.append($("<td></td>").html(tweets.statuses[i].user.screen_name)); 
      row.append($("<td></td>").html(tweets.statuses[i].text + "<br/>")); 
      geoEnabled = tweets.statuses[i].user.geo_enabled; 
      if(geoEnabled){ 
       placeName = tweets.statuses[i].place.name; 
       countryName = tweets.statuses[i].place.country; 
       if(placeName != null){ 
        row.append($("<td></td>").html(placeName + "," + countryName + "<br/>")); 
       } 
       row.append($("<td></td>").html("Location: " + tweets.statuses[i].place.bounding_box.coordinates[0][0][0] + ", " + 
        tweets.statuses[i].place.bounding_box.coordinates[0][0][1] + "<br/>")); 
       row.append($("<td></td>").html(tweets.statuses[i].created_at)); 
      } 
      $("#tweetResult tbody").append(row) 

     } 
    }); 

    setTimeout(arguments.callee, 60000); 
})(); 

Dies ist die Konsole. Protokoll (Tweets) Ausgabe:

Object 
search_metadata 
: 
Object 
statuses 
: 
Array[10] 
__proto__ 
: 
Object 

Kann mir jemand sagen, wie ich diesen Fehler beheben kann. Danke im Voraus.

Antwort

0

i löste es durch ein Timeout-Funktion Hinzufügen

setTimeout(function(){ 
    $('table').tablesorter(); 
}, 10000); 
Verwandte Themen