StanScates / Tweet.js-Mod

Basic wrapper for Seaofclouds / Tweet.js that incorporates functionality with Twitter's v1.1 API
MIT License
234 stars 103 forks source link

Issue with paging #17

Open cebo opened 11 years ago

cebo commented 11 years ago

I have the old code for paging and it seems, it can only fetch one at a time. The paging feature seems to no longer be working. I am in wordpress on this one, so the modpath is a little strange. But, it seems to pull the tweet, just not more than one. Any help?

var options = { username: "cebocampbell", modpath: '<?php echo $blah[path]; ?>/twitter/', page: 1, avatar_size: 32, count: 1, fetch: 5, // 1 + count loading_text: "loading …" };

            var widget = $("#paging .widget"),
              next = $("#paging .next"),
              prev = $("#paging .prev");

            var enable = function(el, yes) {
              yes ? $(el).removeAttr('disabled') :
                    $(el).attr('disabled', true);
            };

            var stepClick = function(incr) {
              return function() {
                options.page = options.page + incr;
                enable(this, false);
                widget.tweet(options);
              };
            };

            next.bind("checkstate", function() {
              enable(this, widget.find("li").length == options.count)
            }).click(stepClick(1));

            prev.bind("checkstate", function() {
              enable(this, options.page > 1)
            }).click(stepClick(-1));

            widget.tweet(options).bind("loaded", function() { next.add(prev).trigger("checkstate"); });
          });
henggana commented 11 years ago

Hai @cebo,

I had same issue. But it working now. Below is my workaround.

   var options = {
          username: "someid", // define twitter usernames
          page: 1,
          avatar_size:0, // avatar size in px
          count: 2, // how many tweets to show
          loading_text: "loading ...",
          template: "{text} {time}", /*"{avatar}{time}{join} {text}"*/
          modpath: "twitter/"
    };

    var widget = jQuery("#tw-feed-wrapper .widget"),
        next = jQuery("#tw-feed-wrapper .next"),
        prev = jQuery("#tw-feed-wrapper .prev");       

    var enable = function (el, yes) {
        yes ? jQuery(el).removeAttr('disabled') : jQuery(el).attr('disabled', true);
    };      

    var stepClick = function (incr) {
            return function () {
                options.page = options.page + incr;
                enable(this, false);
                widget.tweet(options);
            };
    };       

    next.bind("checkstate", function () {
        enable(this, widget.find("li").length == options.count)
    }).click(stepClick(1));       
    prev.bind("checkstate", function () {
        enable(this, options.page > 1)
    }).click(stepClick(-1));

    widget.on("loaded", options ,function (event) {
        options=event.data;

        next.add(prev).trigger("checkstate");

        if(tweets.length>0){
            ...
        }
        else{
            jQuery('.tweet_list').html("empty");
        }
    });

    widget.tweet(options);

oh, and I commenting out tweet.js at line 271.

// async: false,

I'm really new at js, but thank God it's work :)