Derek 朕會功夫
Derek 朕會功夫

Reputation: 94379

Why isn't my Google +1 button code working?

I can't figure out why my code for the Google +1 button isn't working as I expected.

http://jsfiddle.net/DerekL/EF8eE/

When you press the +1 button, an alert should pop up.

Here I got a callback function:

function cb(obj) {
    alert();              //alert
    console.log(obj);     //Then show obj in console
}​

But never the callback never gets fired. I followed every single step according to the spec, and the funniest thing is that I got it working before... But now it just does not work at all. Strange!

Upvotes: 1

Views: 557

Answers (1)

Matt Ball
Matt Ball

Reputation: 360016

From the docs (emphasis added),

you can use this HTML5-valid +1 tag (the class attribute must be set to g-plusone, and any button attributes must be prefixed with data-).

So change

<div class="g-plusone" data-annotation="inline" callback="cb"></div>

to

<div class="g-plusone" data-annotation="inline" data-callback="cb"></div>

Ta-da! http://jsfiddle.net/mattball/FtETf

Upvotes: 5

Related Questions