Кнопка обновления в Twitter Feed Manual - PullRequest
0 голосов
/ 19 марта 2012

пытается обновить мой твиттер, через ссылку / кнопку / что угодно. По какой-то причине это не работает, возможно, из-за неправильного порядка функций в моем файле .js, но я совершенно озадачен и мне нужен совет специалиста!

Тестовая страница находится на Эта страница

Файл .js:

function closeStuff(){

    jQuery('#tweet_container').fadeOut(1000,function(){$('#tweet_container').empty();});
    jQuery('#photosContainer div').delay(1000).fadeIn(1000);
    }

function refreshStuff(user)
{

    jQuery('#tweet_container').empty();
    loadTweets(user);

}


function loadTweets(user){
  // Declare variables to hold twitter API url and user name
  var twitter_api_url = 'http://search.twitter.com/search.json';

  // Enable caching
  $.ajaxSetup({ cache: true });

  // Send JSON request
  // The returned JSON object will have a property called "results" where we find
  // a list of the tweets matching our request query
  $.getJSON(
    twitter_api_url + '?callback=?&rpp=10&q=from:' + user,
    function(data) {
      $.each(data.results, function(i, tweet) {
        // Uncomment line below to show tweet data in Fire Bug console
        // Very helpful to find out what is available in the tweet objects
        //console.log(tweet);

        // Before we continue we check that we got data
        if(tweet.text !== undefined) {
          // Calculate how many hours ago was the tweet posted
          var date_tweet = new Date(tweet.created_at);
          var date_now   = new Date();
          var date_diff  = date_now - date_tweet;
          var hours      = Math.round(date_diff/(1000*60*60));

          // Build the html string for the current tweet
          var tweet_html = '<div class="tweet_text">';
          tweet_html    += '<a href="http://www.twitter.com/';
          tweet_html    += user + '/status/' + tweet.id_str + '" target="_blank">';
          tweet_html    += tweet.text + '<\/a><\/div>';
          tweet_html    += '<div class="tweet_hours">' + hours;
          tweet_html    += ' hours ago<\/div>';

          // Append html string to tweet_container div
          $('#tweet_container').hide().append(tweet_html).fadeIn(1000);
        }

      });
    }

  );

  $('#tweet_container').hide().append('<a href="#" class="refresh" onClick="refreshStuff(user);">Refresh</a>').delay(1000).fadeIn(1000);
  $('#tweet_container').hide().append('<a href="#" class="close" onClick="closeStuff();">Back</a>').delay(1000).fadeIn(1000);

}




function clickPhoto(id){


var user;

switch(id)
{
case 1: user='cantqwontq';break;
case 2: user='carnivalrag';break;
case 3: user='samdlc';break;

default: user='0';break;
}



//jQuery('#tweet_container').empty();

jQuery('#photosContainer div').fadeOut();


loadTweets(user);



}

1 Ответ

0 голосов
/ 19 марта 2012

Если вы откроете веб-консоль (ctrl + shift + k) в Firefox и нажмете ссылку / кнопку Обновить, вы увидите ошибку «пользователь не определен»

Я думаю, что проблема здесь

<a class="refresh" onclick="refreshStuff(user);" href="#">Refresh</a>

при добавлении попробуйте user.toString ();

попробуй {{{

    "$('#tweet_container').hide().append('<a href="#" class="refresh" onClick="refreshStuff(
'user.toString()');">Refresh</a>').delay(1000).fadeIn(1000);

}}} * +1011 *

Приветствия:)

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...