I'm using two plug开发者_如何转开发ins:
1) Load tweets 2) Paginate those tweets
But need to load the tweets for paginate. I use the following code but not working
$(document).ready( function(){
$("#twittTime").tweet({
avatar_size: 32,
count: 20,
fetch: 20,
template: "{text} {time}",
filter: function(t){ return ! /^@\w+/.test(t["tweet_raw_text"]); },
username: "user",
loading_text: "Cargando Timeline ..."
});
$(".tweet_list").live({ load: function() {
$('.tweet_list').easyPaginate({
step:4,
alert: 'Hola'
});
},
});
});
I'm the maintainer of jquery.tweet.js
. The widget triggers a "loaded" event after the tweets have been rendered into the page, so you can simply do this:
$(document).ready( function(){
$("#twittTime").tweet({
avatar_size: 32,
count: 20,
fetch: 20,
template: "{text} {time}",
filter: function(t){ return ! /^@\w+/.test(t["tweet_raw_text"]); },
username: "user",
loading_text: "Cargando Timeline ..."
}).bind("loaded", function() {
$('.tweet_list').easyPaginate({
step:4,
alert: 'Hola'
});
});
});
There's an example of that in the bundled index.html
file and on the tweet.seaofclouds.com page.
The plugin should have a callback method that tells you when it's complete. From there you run your $(".tweet_list")
function.
EDIT:
I'm editing here because it's better for showing code examples. If you can edit the JS plugin I would suggest adding in your own callback...it's really, really easy.
First lets add a complete()
method to the plugin. If you open tweet.js
then look for var s = $.extend({
, this is where the defaults are set for the plugin. Inside the $.extend()
method there will be a list of settings, go all the way down to the bottom and add this:
Roughly line #30:
filter: function(tweet) {
return true;
},
/* Our callback method we are adding */
complete: function() {
return true;
}
Then we need to call this function at the end of the JSON AJAX request.
Go down to line #201 just under the if (s.refresh_interval)
statement. Then after the closing }
add s.complete();
What you've basically done is call the complete function after the content has loaded. I tested it locally and it's working so try it out and see if it does what you're looking for.
Good luck!
Edit 2: I found the plugin on Github and submitted this feature so hopefully when/if they come out with an update it will have this so you don't have to add it every time.
精彩评论