0

I am looking to change a DIV when I know a user is following me. I cant get the code to fire the alerts.
The follow button does show up, but after i click and follow, nothing happens.

twttr.anywhere(function (T) {
    T("#followplaceholder").followButton('twitterapi');
    function follow(){
        T.currentUser.isFollowing('twitterapi'), function(e){
            if (e == true){
                alert("following");
            } else {
                 alert("not following");
            }
        }; 
    }                                                             
});

Any help would be great!


Here is the code i am trying to use now. Where do i call the function to get it fired? Or should i just take the function part out?

twttr.anywhere(function (T) {
    T("#followplaceholder").followButton('twitterapi');
    function follow(){
        T.currentUser.isFollowing('twitterapi'), function(e){
            if (e == true){
                alert("following");
            } else {
                 alert("not following");
            }
        }; 
    }                                                             
});
ChrisF
  • 134,786
  • 31
  • 255
  • 325
kkampen
  • 437
  • 8
  • 22

3 Answers3

1

you have an extra ) after 'twitterapi'

try this:

function follow(){
    T.currentUser.isFollowing('twitterapi', function(e){
        if (e == true){
            alert("following");
        } else {
            alert("not following");
        }
    }; 
}
woppywush
  • 11
  • 1
0

Is the follow funcion even triggered? It's just standing there doing nothing? And like the others sad there is a piece of PHP inthere..., it has to be a ) i think.

Also watch your console log for errors.

seymar
  • 3,993
  • 6
  • 25
  • 30
  • How would i call the function? I am not much of a javascript guy. – kkampen Feb 09 '11 at 07:05
  • It should be triggered when you click the button, so add an `onclick` event to the button? It would be nice when you post the code of your hole page so we can see the button's html etc. – seymar Feb 11 '11 at 09:43
0

T.currentUser.isFollowing('tweetapi']?>', function(e){

A straight-forward bug. ?> is php code, so you might want to use ) instead of ]?>

alexyorke
  • 4,224
  • 3
  • 34
  • 55
  • Yeah actually that was a mistake on my part. I was having tweetapi filled by a constant I set in my config file. The above is now correct to reflect the right code. I still never did get it working though – kkampen Feb 09 '11 at 07:04