开发者

Load next twitter user from Array and get their tweets with blogger.js

I have a javascript array of twitter usernames. I load the first twitter user and their last 5 tweets using blogger.js. I want to have an html button/link for previous and next to load the next/previous u开发者_StackOverflow社区sername and their tweets replacing the current username and tweets (inner html) by calling blogger.js. How do I iterate over the javascript array using onclick and keep track of where I am in the array? I can call blogger.js from the function I call with onclick. Am I going about this the right way by trying to use jquery? Just looking for some ideas and guidance.


As far as I can see you, it seems you just need to keep some state information of what the current index you are at in the array. In the main script trying something like:

var window.CHIP = {twitterArrayIndex=0}

then with in your event listenter use the CHIP.twitterArrayIndex property:

on your next button next(){ CHIP.twitterArrayIndex =CHIP.twitterArrayIndex +1; // lookup value using CHIP.twitterArrayIndex }

on your previous button previous(){ CHIP.twitterArrayIndex =CHIP.twitterArrayIndex +1; // lookup value using CHIP.twitterArrayIndex }

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜