3

I'm having some strange issue when I place the callback function inside a module, the library cannot seem to find the function, so if I use:

var Auth = (function () {
    var gPlusSignCallback = function () {
      console.log("Google plus signin call back done!");
  };

  return {
      gPlusSignCallback: gPlusSignCallback
  };
}());

And in the html snipped of the Google+ Signing button I use:

data-callback="Auth.gPlusSignCallback"

I get the following error:

Callback function named "Auth.gPlusSignCallback" not found

If I put the gPlusSignCallback outside the module everything works well. I checked the documentation and it says that the value must be a function in the global namespace. So is it not working by design? I need to make global variable that makes reference to the function in the module?

4

2 回答 2

6

The signin callback must be a global function for the widget to find it. Wrap your callback as such:

function onSigninCallback(e){
    Auth.gPlusSignCallback(e);
}
于 2013-03-30T16:53:28.643 回答
2

An alternative is to use the Javascript API to render the button. If you do that, you can pass a reference to a function as callback. This is an example from PhotoHunt, the End-to-end Google+ Platform sample application.

于 2013-04-02T06:26:43.587 回答